Input number and check prime or not using for loop in Python
for Loop - Question 10
In this question, we will see how to input a number and check if it is a prime number or not in Python programming using for loop. To know more about for loop click on the for loop lesson.
Q10) Write a program in Python to input a number and check if it is a prime number or not using for loop.
n=int(input('Enter a number '))
for i in range(1,n+1):
fc=fc+1 # counting the factors of the given number
if fc==2: # a prime number has only two factors
print('Not Prime Number')
Enter a number 17 Prime Number