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 _33.Prime_Checker
- {
- class PrimeChecker
- {
- static void Main(string[] args)
- {
- long num = long.Parse(Console.ReadLine());
- bool isPrime = IsPrime(num);
- Console.WriteLine(isPrime);
- }
- private static bool IsPrime(long num)
- {
- int div = 2;
- bool isPrime = true;
- if (num <= 1)
- {
- isPrime = false;
- }
- else
- {
- while (div <= Math.Sqrt(num))
- {
- if (num % div == 0)
- {
- isPrime = false;
- }
- div++;
- }
- }
- return isPrime;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement