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 PrimeChecker
- {
- class PrimeChecker
- {
- static void Main()
- {
- long n = long.Parse(Console.ReadLine());
- Console.WriteLine(isPrime(n));
- }
- public static bool isPrime(long n)
- {
- if(n <= 1)
- {
- return false;
- }
- int maxDivider = (int)Math.Sqrt(n);
- for (long divider = 2; divider <= maxDivider; divider++)
- {
- if(n % divider == 0)
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment