Next Index Previous

Python Examples

2. Program to check whether the given number is prime or not.

n = int(input('Enter a value'))
i=1
count=0

while i<=n:
	if n%i==0:
		count = count+1
	i=i+1	

if count==2:
	print('Prime')
else:
	print('Not prime')	
Input :
17
Output :
Prime



Father of Python Language

Guido-van-Rossum

Guido van Rossum

Born: January 31, 1956, Netherlands