Advertisement
iggnaccy

łukasz pacz

Mar 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. IEnumerable<int> PrimeCollection()
  2.         {
  3.             List<int> r = new List<int>();
  4.             r.Add(2);
  5.             yield return 2;
  6.             int i = 3;
  7.             while(i < int.MaxValue)
  8.             {
  9.                 for(int j = 0; j < r.Count; j++)
  10.                 {
  11.                     if(i % j == 0)
  12.                     {
  13.                         i += 2;
  14.                         j = 0;
  15.                     }
  16.                 }
  17.                 r.Add(i);
  18.                 yield return i;
  19.             }
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement