Prime Number

                                        Prime Number

 You are given an integer N. You need to print the series of all prime numbers till N.

Input Format

The first and only line of the input contains a single integer N denoting the number till where you need to find the series of prime number.

Output Format

Print the desired output in single line separated by spaces.

Constraints

1<=N<=1000

Sample Input
9
Sample Output
 
2 3 5 7
 SOLUTION In Python 3
# Write your code here
def checkprime(n):
for i in range(2, n):
if n%i==0:
return False
return True
num=int(input())
if num<2:
print()
else:
for i in range(2, num+1):
if checkprime(i):
print(str(i),end=" ")





Comments

Popular Posts