Find prime numbers
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.
Input Format:
The input contains a single positive integer ‘N’.
Output Format :
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.
Constraints:
2 <= N <= 10^7
Where ‘N’ is the given positive integer.
Time Limit: 1sec
Be the first one to answer
Add answer anonymously...
Top LTIMindtree Graduate Engineer Trainee (Get) interview questions & answers
Popular interview questions of Graduate Engineer Trainee (Get)
Top HR questions asked in LTIMindtree Graduate Engineer Trainee (Get)
>
LTIMindtree Graduate Engineer Trainee (Get) Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app