Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PrimeNumberCheck
- {
- static void Main()
- {
- int input = int.Parse(Console.ReadLine());
- int divider = 1;
- bool answer = false;
- int count = 0;
- for (divider = 1; divider <= input; divider++) // cicle run until it reaches the value of input number, because there is no sense to divide at larger number
- {
- if (input % divider == 0)
- {
- count++; // count how many times the number is divided without remainder
- }
- }
- if (count == 2) // To be true , the input number must by divided without remainder only 2 times, with "1" and itself.
- {
- answer = true;
- }
- Console.WriteLine(answer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement