#C13401. Generate Prime Numbers
Generate Prime Numbers
Generate Prime Numbers
You are given a single integer N
. Your task is to generate the first N
prime numbers. A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself. To check if a number n
is prime, you only need to verify that no number up to \(\sqrt{n}\) divides it evenly.
Example: If N = 5
, the first five prime numbers are 2, 3, 5, 7, 11
.
inputFormat
The input consists of a single integer N
(N \geq 1
) read from standard input.
outputFormat
Output the first N
prime numbers separated by a single space on one line. There should be no extra spaces at the beginning or the end of the output.
1
2