Welcome folks today in this post we will be finding prime numbers
upto N
in python. All the full source code of the application is given below.
Get Started
In order to get started you need to make an app.py
file and copy paste the following code to it
app.py
1 2 3 4 5 6 7 8 9 |
n = int(input("Enter end number of Range")) for i in range(0, n+1): if i>1: for j in range(2,i): if(i % j==0): break else: print(i) |
As you can see we are taking the value of n
from the user and then we are printing all the prime
numbers that come before that number of n
.
Now if you execute the python
script by executing the below command
python app.py