Next Prime

Next Prime

Medium Computer Mathematics Primes & Factorization 41 views
Explanation Complexity

Problem Statement

Given n, print the smallest prime >= n.

Input Format

One integer n.

Output Format

One integer prime.

Example

30
31

Constraints

0

Input / Output Format

Input Format
One integer n.
Output Format
One integer prime.
Constraints
0

Examples

Input:
30
Output:
31

Example Solution (Public)

Computer Mathematics
Loop x from n upward, test primality, stop at first prime.

Official Solution Code

Loop x from n upward, test primality, stop at first prime.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.