Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n, c = 2, primo = 0;
- Console.WriteLine("Digite um numero:");
- n = int.Parse(Console.ReadLine());
- if (n == 1 || n == 2)
- {
- Console.WriteLine(n + " é primo");
- return;
- }
- while (c <= n)
- {
- if (n % c == 0)
- {
- primo++;
- }
- c++;
- }
- if (primo > 1)
- {
- Console.WriteLine(n + " não é primo");
- }
- else
- {
- Console.WriteLine(n + " é primo");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement