6844.Next Prime

Time Limit: 1s Memory Limit: 512MB

Given a positive integer $n$ , find the next prime number after it.

Input Format(From the terminal/stdin)

The first line has an integer $t$ : the number of tests.

After that, each line has a positive integer $n$ .

  • $1 \le t \le 20$
  • $1 \le n \le 10^{12}$

Output Format(To the terminal/stdout)

For each test, print the next prime after $n$ .

Sample Input

Copy
5
1
2
3
42
1337
 \n
 \n
 \n
 \n
  \n
    \n

Sample Output

Copy
2
3
5
43
1361
 \n
 \n
 \n
  \n
    \n
Source: CSES, Mathematics, 3396

Submit

请先 登录

© 2025 FAQs