A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
The following Python Code snippet to check prime number or not.
Python3 Code:
1 2 3 4 5 6 7 8 9 10 11 12 | counter=0 num=input('Enter a Number: ') for i in range(2,int(num)): if(int(num)%i==0): counter+=1 break if(counter!=0): print('{0} is not a prime number'.format(num)) else: print('{0} is a prime number'.format(num)) |
Output: