SHARE
TWEET

Untitled

berkman Oct 4th, 2017 143 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace PrimeChecker
  2. {
  3.     using System;
  4.  
  5.     public class StartUp
  6.     {
  7.         public static void Main()
  8.         {
  9.             long n = long.Parse(Console.ReadLine());
  10.             Console.WriteLine(IsPrime(n));
  11.         }
  12.  
  13.         public static bool IsPrime(long n)
  14.         {
  15.             bool isPrime = true;
  16.             for (long i = 2; i <= Math.Sqrt(n); i++)
  17.             {
  18.                 if (n % i == 0 || n <= 1)
  19.                 {
  20.                     isPrime = false;
  21.                 }
  22.             }
  23.             return isPrime;
  24.         }
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top