Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _10CheckPrime
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string isPrime = "Prime";
- if(n<2)
- Console.WriteLine("Not Prime");
- else
- {
- for (int i = 2; i <n; i++) // or i<= Math.Sqrt(n)
- {
- if (n % i == 0)
- {
- isPrime = "Not Prime";
- break;
- }
- }
- Console.WriteLine(isPrime);
- }
- //int n = int.Parse(Console.ReadLine());
- //bool isPrime = true;
- //for (int i = 2; i < n; i++) // Math.Sqrt(n)
- //{
- // if (n % i == 0)
- // {
- // isPrime = false;
- // break;
- // }
- //}
- //if (isPrime)
- //{
- // Console.WriteLine("Prime");
- //}
- //if (n < 2)
- // Console.WriteLine("Not Prime");
- //else
- // Console.WriteLine("Not Prime");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement