Python Program to Print all Prime Numbers from 1 to N numbers
Print all the prime number from 1 to N number
Step to create these program:
- First we take the first number as 1
- Then we take the second number from the user
- Then we iterate the for loop from first to last+1
- Then we check the number is greater than 1
- Then we iterate again for loop from 2 to num
- Then we check to divide the num from the for loop and check is equal to zero
- Other wise print num
- first= 1
- #Take the input from the user:
- last= int(input("Enter the number: "))
- for num in range(first,last+ 1):
- if num > 1:
- for i in range(2,num):
- if (num % i) == 0:
- break
- else:
- print(num)
Output :
Enter the number: 10
2
3
5
7
i can create your blog more cool like me
infonexx.blogspot.com
for free
i like you post bro