Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
One liner recursive prime generator
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { IEnumerable<int> primes = null; primes = Enumerable.Range(0,int.MaxValue).Where(x=>x==2||(x>2&&primes.TakeWhile(p=>p<=Math.Sqrt(x)).All(p=>x%p!=0))); primes.TakeWhile(x=>x<=1000).ToList().ForEach(Console.WriteLine); } } }
run
|
edit
|
history
|
help
1
Plt-D v.0.8.4
10
Hallo world
Sum Matrix Column
Md5 hash
Upgrade
Interface IEnumerable
hello
asxsdf
2.1 Basic types: Lists and Linq beauty