Problems > The Next Prime

The Next Prime

Difficulty: 1500 4000 ms 128 MB

math number-theory

Print the smallest prime strictly greater than N.

Input: one integer N.

Output: the next prime after N.

Constraints:

  • 1 ≤ N ≤ 1012

Sample Tests

Input 1
10
Output 1
11
Input 2
1
Output 2
2

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.