Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
01-SI
Pizzas & List of Tuples
List_methods
V 1.2
memes
Understandiing Virtual, Override, New Keyword in C#
XPath
Is first character of MD5 hash evenly distributed?
Dijkstra’s shortest path algorithm
ConcurrentStack<T>
Please log in to post a comment.