Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<int> notPrime = new List<int>();
- // sieve of Eratosthenes - excludes gradually all numbers which can be divided by 2, 3, 5, 7
- // you can confirm this with the y locals values in debug mode
- // I have chosen this loop solution, because the loop length can be easily ammended
- // to include any bigger range of numbers
- for (int x = 2; x < 100; x++)
- {
- for (int y = x * 2; y < 100; y = y + x)
- {
- if (!notPrime.Contains(y))
- {
- notPrime.Add(y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement