Skip to content
Closed
Changes from all 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
24 changes: 24 additions & 0 deletions maths/Next_Prime_Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""

Check failure on line 1 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N999)

maths/Next_Prime_Number.py:1:1: N999 Invalid module name: 'Next_Prime_Number'

Check failure on line 1 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N999)

maths/Next_Prime_Number.py:1:1: N999 Invalid module name: 'Next_Prime_Number'
In the ancient city of Numeria, legends speak of an oracle whose whispers could bend the very fabric of mathematics.

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:117: W291 Trailing whitespace

Check failure on line 2 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Next_Prime_Number.py:2:89: E501 Line too long (117 > 88)

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:117: W291 Trailing whitespace

Check failure on line 2 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Next_Prime_Number.py:2:89: E501 Line too long (117 > 88)
Travelers from distant lands would bring her a number, and in return, she would reveal its future: the very next prime number.

Check failure on line 3 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Next_Prime_Number.py:3:89: E501 Line too long (126 > 88)

Check failure on line 3 in maths/Next_Prime_Number.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Next_Prime_Number.py:3:89: E501 Line too long (126 > 88)
Your task is to embody the oracle's wisdom. You will be given a number.
You must find the smallest prime number that is strictly greater than it.
"""
def check_prime(n):
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