An application of the Sieve query operator. | Lecture 16 - slide 11 : 11 Program 2 |
using System; using System.Collections.Generic; using System.Linq; class Program{ static void Main(string[] args){ IEnumerable<long> naturalNumbers = 2L.AdInfinitum(), primes = naturalNumbers.Sieve(); foreach (long i in primes.Take(100)) Console.WriteLine(i); Console.ReadLine(); } } |