Please enter your email address or userHandle.
Given a number N, calculate the prime numbers upto N using Sieve of Eratosthenes.
The first line of the input contains T denoting the number of testcases. T testcases follow. Each testcase contains one line of input containing N.
For all testcases, in a new line, print all the prime numbers upto or equal to N.
1 <= T<= 100
1 <= N <= 104
2 3 5 7
2 3 5 7 11 13 17 19 23 29 31
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.