Problem of the day
You are given a positive integer ‘N’. Your task is to print all prime numbers less than or equal to N.
Note: A prime number is a natural number that is divisible only by 1 and itself. Example - 2, 3, 17, etc.
You can assume that the value of N will always be greater than 1. So, the answer will always exist.
The input contains a single positive integer ‘N’.
Print single space-separated prime numbers less than or equal to ‘N’ in increasing order.
Note :
You do not need to print anything; it has already been taken care of. Just implement the function.
2 <= N <= 10^7
Where ‘N’ is the given positive integer.
Time Limit: 1sec
7
2 3 5 7
For the given input, all prime numbers from 2 to 7 are 2, 3, 5 and 7.
30
2 3 5 7 11 13 17 19 23 29