#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 . A prime is an integer greater than 1 with exactly two positive divisors. Return itself if prime; for , return 2. A trial-division solution needs no array.
Input
One integer .
Output
Print the smallest prime not smaller than .
Subtasks
-
Subtask 1 (20%): .
-
Subtask 2 (30%): .
-
Subtask 3 (50%): .
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.