Skip to content

Commit 443836e

Browse files
Rename Next_Prime_Number.py to next_prime_number.py
1 parent 2d22975 commit 443836e

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

maths/Next_Prime_Number.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

maths/next_prime_number.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
In the ancient city of Numeria,
3+
legends speak of an oracle whose whispers
4+
could bend the very fabric of mathematics.
5+
Travelers from distant lands would bring
6+
her a number, and in return, she would reveal
7+
its future: the very next prime number.
8+
Your task is to embody the oracle's wisdom.
9+
You will be given a number.
10+
You must find the smallest prime number
11+
that is strictly greater than it.
12+
"""
13+
def check_prime(n):
14+
if n<=1:
15+
return False
16+
if n<=3:
17+
return True
18+
if n%2==0 or n%3==0:
19+
return False
20+
temp=5
21+
while temp*temp<=n:
22+
if n%temp==0 or n%(temp+2)==0:
23+
return False
24+
temp+=6
25+
return True
26+
n=int(input())
27+
next_prime=n+1
28+
while not check_prime(next_prime):
29+
next_prime+=1
30+
print(next_prime)

0 commit comments

Comments
 (0)