Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PrimeNumberCheck
- {
- class Program
- {
- static void Main()
- {
- Console.Write("Enter the number: ");
- int n = int.Parse(Console.ReadLine());
- if (n <= 1) { Console.WriteLine("false"); return; }
- for (int i = 2; i <= Math.Sqrt(n); i++)
- {
- if ((n % i == 0 && n != i))
- {
- Console.WriteLine("false"); return;
- }
- }
- Console.WriteLine("true");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement