Python3 Prime Number
# Python3.x Python Prime Number Check
[ Python3 Examples](#)
A natural number greater than 1 that cannot be divided by any other natural number (prime numbers) except 1 and itself (e.g., 2, 3, 5, 7). In other words, it has no other factors besides 1 and itself.
## test.py file:
# -*- coding: UTF-8 -*-# Filename : test.py# author by : www..com# Python program to check if the user-input number is prime# User input number num = int(input("Enter a number: "))# Prime numbers are greater than 1 if num>1: # Check for factors for i in range(2,num): if(num % i) == 0: print(num,"is not a prime number")print(i,"multiplied by",num//i,"is",num)break else: print(num,"is a prime number")# If the input number is less than or equal to 1, it is not prime else: print(num,"is not a prime number")
Executing the above code produces the following output:
$ python3 test.py Enter a number: 11 is not a prime number $ python3 test.py Enter a number: 44 is not a prime number2 multiplied by 2 is 4 $ python3 test.py Enter a number: 55 is a prime number
[ Python3 Examples](#)
YouTip