MeetCode
Next Prime
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
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
Input
30
Output
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
Wrap
Copy
Loop x from n upward, test primality, stop at first prime.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
30
Expected Output
31
Compile Output
Error
Output
Please
login
to submit solutions.