Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1.      List<int> notPrime = new List<int>();
  2.  
  3.         // sieve of Eratosthenes - excludes gradually all numbers which can be divided by 2, 3, 5, 7
  4.         // you can confirm this with the y locals values in debug mode
  5.         // I have chosen this loop solution, because the loop length can be easily ammended
  6.         // to include any bigger range of numbers
  7.  
  8.         for (int x = 2; x < 100; x++)
  9.         {
  10.             for (int y = x * 2; y < 100; y = y + x)
  11.             {
  12.  
  13.                 if (!notPrime.Contains(y))
  14.                 {
  15.                     notPrime.Add(y);
  16.                 }
  17.  
  18.             }
  19.  
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement