Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SieveOfErathosthen
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- bool[] A = new bool[n];
- for (int i = 2; i < n; i++)
- {
- A[i] = true;
- }
- for (int i = 2; i < n; i++)
- {
- if (A[i])
- {
- for (int j = 2; (j * i) < n; j++)
- {
- A[j * i] = false;
- }
- }
- if (A[i])
- {
- Console.Write("{0} ", i);
- }
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement