Advertisement
apenev

10

Apr 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp4
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. bool isPrimer = n > 1;
  15.  
  16. for (int i = 2; i <= Math.Sqrt(n); i++)
  17. {
  18. if (n % i == 0)
  19. {
  20. isPrimer = false;
  21. break;
  22. }
  23.  
  24.  
  25. }
  26.  
  27. if (isPrimer)
  28. {
  29. Console.WriteLine("Prime");
  30. }
  31. else
  32. {
  33. Console.WriteLine("Not Prime");
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement