Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Prime_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- long n = long.Parse(Console.ReadLine());
- Console.WriteLine(isPrime(n));
- }
- public static bool isPrime(long n)
- {
- if (n == 0 || n == 1)
- {
- return false;
- }
- if (n == 2)
- {
- return true;
- }
- var temp = Math.Floor(Math.Sqrt(n));
- for (long i = 3; i <= temp; i+=2)
- {
- if (n % i == 0)
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement