Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Prime
- {
- static void Main()
- {
- //int num = int.Parse(Console.ReadLine());
- int num = 17;
- int count = 0;
- if (num < 0)
- {
- for (int i = -1; i <= (num / 2); i--)
- {
- if (num % i == 0)
- {
- count++;
- }
- }
- if (count == 1)
- {
- Console.WriteLine("The number is prime");
- }
- }
- else
- for (int i = 1; i <= (num / 2); i++)
- {
- if (num % i == 0)
- {
- count++;
- }
- }
- if (count == 1)
- {
- Console.WriteLine("The number is prime");
- }
- else
- {
- Console.WriteLine("The number is NOT prime");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement