#C7836. Generate Prime Numbers
Generate Prime Numbers
Generate Prime Numbers
This problem requires you to generate the first n prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Formally, a number \(p\) is prime if and only if for every integer \(a\) such that \(2 \leq a \leq \sqrt{p}\), \(a\) does not divide \(p\).
You need to read an integer from the standard input and then output the first n prime numbers in increasing order, separated by spaces.
inputFormat
The input consists of a single line containing an integer n
(0 ≤ n ≤ 1000), where n
indicates how many prime numbers are to be generated.
outputFormat
Output the first n
prime numbers separated by a single space. If n
equals 0, output an empty line.
5
2 3 5 7 11