Advertisement
YavorJS

Check prime reversed

Jun 30th, 2016
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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.  
  8. class Program
  9. {
  10. static void Main()
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13. string prime = "Not Prime";
  14. int duplicate = 0;
  15. for (int i = 2; i <= n; i++)
  16. {
  17. if (n % i == 0 && n % 1 == 0 && n > 1)
  18. {
  19. prime = "Prime";
  20. }
  21. if (n % i == 0)
  22. {
  23. duplicate++;
  24. }
  25. }
  26.  
  27. if (duplicate > 1)
  28. {
  29. prime = "Not Prime";
  30. }
  31.  
  32. Console.WriteLine(prime);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement