Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class SieveOfEratosthenes
- {
- static void Main()
- {
- int[] nums = new int[10000000];
- for (int i = 0; i < nums.Length; i++)
- {
- nums[i] = i + 1;
- }
- for (int index = 0; index < nums.Length; index++)
- {
- for (int check = 2; check <= nums[index]; check++)
- {
- bool checking = nums[index] % check == 0;
- if (checking == true && (check == nums[index]))
- {
- Console.WriteLine(nums[index]);
- }
- else if (checking == true && (check != nums[index]))
- {
- break;
- }
- else if (checking == false)
- {
- if (check <= nums[index])
- {
- continue;
- }
- else if (check == nums[index])
- {
- Console.WriteLine(nums[index]);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement