Advertisement
berkman

Untitled

Oct 4th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement