How to check the prime number in python?
![](https://pythonpoint.net/wp-content/uploads/2020/12/Green-and-Black-Illustrated-Video-Game-Controller-Vector-YouTube-Channel-Cover-8-1024x576.jpg)
Prime numbers are those which is divisible by the number itself and one.
Here we’ll see a code here by which we can check whether a number is prime or not.
e.g.,
n = int(input("Enter a number: ")) if n > 1: for i in range(2,n): if (n % i) == 0: print(n,"is not a prime number") print(i,"times",num//i,"is", n) break else: print(n,"is a prime number") else: print(n,"is not a prime number")
![](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-981-1024x535.png)
This is how we can check whether a number is a prime number or not.
Subscribe
Login
Please login to comment
0 Discussion