#CCBCHBON0000025. Số nguyên tố đầu tiên không nhỏ hơn n (First Prime Not Smaller Than n)

Số nguyên tố đầu tiên không nhỏ hơn n (First Prime Not Smaller Than n)

First Prime Not Smaller Than n

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Find the smallest prime p≥np\ge n. A prime is an integer greater than 1 with exactly two positive divisors. Return nn itself if prime; for n=1n=1, return 2. A trial-division solution needs no array.

Input

One integer 1≤n≤1061\le n\le10^6.

Output

Print the smallest prime not smaller than nn.

Subtasks

  • Subtask 1 (20%): 1≤n≤301\le n\le 30.

  • Subtask 2 (30%): 1≤n≤100001\le n\le 10000.

  • Subtask 3 (50%): 1≤n≤10000001\le n\le 1000000.

Examples

Example 1

Input:

14

Output:

17

Explanation:

Check candidates beginning at 14; the first prime is 17.

Example 2

Input:

1

Output:

2

Explanation:

Check candidates beginning at 2; the first prime is 2.