#K56152. Sieve of Eratosthenes
Sieve of Eratosthenes
Sieve of Eratosthenes
In this problem, you need to implement the Sieve of Eratosthenes algorithm to find all the prime numbers less than a given integer ( n ). The algorithm works by iteratively marking the multiples of each prime starting from 2. Your program will read an integer from standard input and output all prime numbers less than ( n ) in increasing order, separated by a single space. If there is no prime number less than ( n ), output nothing.
inputFormat
The input consists of a single integer ( n ) on one line, where ( n ) is the upper bound. ( n ) will be a non-negative integer.
outputFormat
Output all prime numbers less than ( n ) in a single line, separated by a space. If there are no such primes, output an empty line.## sample
10
2 3 5 7