Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions maths/next_prime_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
In the ancient city of Numeria,

Check failure on line 2 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:2:32: W291 Trailing whitespace
legends speak of an oracle whose whispers

Check failure on line 3 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:3:42: W291 Trailing whitespace
could bend the very fabric of mathematics.

Check failure on line 4 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:4:43: W291 Trailing whitespace
Travelers from distant lands would bring

Check failure on line 5 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:5:41: W291 Trailing whitespace
her a number, and in return, she would reveal

Check failure on line 6 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:6:46: W291 Trailing whitespace
its future: the very next prime number.
Your task is to embody the oracle's wisdom.

Check failure on line 8 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:8:44: W291 Trailing whitespace
You will be given a number.
You must find the smallest prime number

Check failure on line 10 in maths/next_prime_number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

maths/next_prime_number.py:10:40: W291 Trailing whitespace
that is strictly greater than it.
"""
def check_prime(n):
Comment thread
swamini-jadhav marked this conversation as resolved.
if n<=1:
return False
if n<=3:
return True
if n%2==0 or n%3==0:
return False
temp=5
while temp*temp<=n:
if n%temp==0 or n%(temp+2)==0:
return False
temp+=6
return True
n=int(input())
next_prime=n+1
while not check_prime(next_prime):
next_prime+=1
print(next_prime)
Loading