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 Practice
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- bool[] prime = new bool[n+1];
- for (int i = 0; i < prime.Length; i++)
- {
- prime[i] = true;
- }
- prime[0] = prime[1] = false;
- for (int i = 2; i < prime.Length; i++)
- {
- if (prime[i])
- {
- Console.Write(string.Join(", ",i));
- for (int j = i; j < prime.Length; j+=i)
- {
- prime[j] = false;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment