Advertisement
Guest User

Untitled

a guest
Mar 7th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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 proverka_za_prosto_chislo
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. bool prime = true;
  15. for (int i = 2; i <= Math.Sqrt(n); i++)
  16. {
  17. if (n % i == 0)
  18. {
  19. prime = false;
  20. break;
  21. }
  22.  
  23. }
  24.  
  25.  
  26. if (prime)
  27. {
  28. Console.WriteLine("Prime");
  29. }
  30.  
  31. else
  32. {
  33. Console.WriteLine( "Not prime");
  34. }
  35.  
  36.  
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement