← Back to challenges

Next Prime

PythonHardmathnumbersloops

Instructions

Given an integer, create a function that returns the next prime. If the number is prime, return the number itself.

Examples

next_prime(12) ➞ 13

next_prime(24) ➞ 29

next_prime(11) ➞ 11
# 11 is a prime, so we return the number itself.

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.