Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SieveOfSimo
- {
- class Program
- {
- static void Main(string[] args)
- {
- long n = long.Parse(Console.ReadLine());
- bool[] primes = new bool[n + 1];
- for (long i = 2; i < primes.Length; i++)
- {
- primes[i] = true;
- }
- for (long i = 2; i < primes.Length; i++)
- {
- if (primes[i])
- {
- Console.Write(i + " ");
- for (long j = i * 2; j < primes.Length; j += i)
- {
- primes[j] = false;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement