Problem of the day
Write a Program to check whether the given number N is prime or not.
For a given number N check if it is prime or not. A prime number is a number that is only divisible by 1 and itself.The only line of input contains a single integer N.
Output Format :
The only line of the output prints either true or false.
0 <= N <= 10,000
5
true
10
false
10 has 2 factors 2, 5.
In the program, a for loop is iterated from i = 2 to i < n.
In each iteration, whether n is perfectly divisible by i is checked using:
if (n % i == 0)
If n is perfectly divisible by I, n is not a prime number. In this case, the flag is set to False.
After the loop, if n is a prime number, the flag will still be True. However, if n is a non-prime number, the flag will be False.