Generate Primes

5

1 votes
Problem

Given a number 'N' generate all the primes smaller than or equal to 'N'.

Try it using Sieve of Eratosthenes.

 

Sample Input
2
30
80
Sample Output
2 3 5 7 11 13 17 19 23 29 
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Input: 30

Output: 2 3 5 7 11 13 17 19 23 29 

Contributers:
Editor Image

?