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 _06_PrimeChecker
- {
- class Program
- {
- static void Main(string[] args)
- {
- long n = long.Parse(Console.ReadLine());
- Console.WriteLine(IsPrime(n));
- }
- private static bool IsPrime(long n)
- {
- if (n == 2)
- {
- return true;
- }
- if (n % 2 == 0 || n == 1)
- {
- return false;
- }
- for (int i = 3; i <= (long)Math.Sqrt(n); i+=2)
- {
- if (n % i == 0)
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement