All prime numbers

Moderate
0/80
29 upvotes
Asked in companies
Urban Company (UrbanClap)QualcommHackerEarth

Problem statement

Given an integer N, print all the prime numbers that lie in the range 2 to N (both inclusive).

Detailed explanation ( Input/output format, Notes, Images )
Input Format :
Integer N
Output Format :
Prime numbers in different lines
Constraints :
1 <= N <= 100
Sample Input 1:
9
Sample Output 1:
2
3
5
7
Sample Input 2:
20
Sample Output 2:
2
3
5
7
11
13
17
19
Approaches (1)
Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
All prime numbers
Full screen
Console