Advertisement
Guest User

prova

a guest
Nov 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. int n, c = 2, primo = 0;
  2. Console.WriteLine("Digite um numero:");
  3. n = int.Parse(Console.ReadLine());
  4. if (n == 1 || n == 2)
  5. {
  6. Console.WriteLine(n + " é primo");
  7. return;
  8. }
  9. while (c <= n)
  10. {
  11. if (n % c == 0)
  12. {
  13. primo++;
  14. }
  15. c++;
  16. }
  17. if (primo > 1)
  18. {
  19. Console.WriteLine(n + " não é primo");
  20. }
  21. else
  22. {
  23. Console.WriteLine(n + " é primo");
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement