mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-19 19:03:02 +08:00
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python * sort() --> sorted()
This commit is contained in:
@ -6,14 +6,8 @@ By listing the first six prime numbers:
|
||||
|
||||
We can see that the 6th prime is 13. What is the Nth prime number?
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
|
||||
def isprime(n):
|
||||
if n == 2:
|
||||
@ -30,7 +24,7 @@ def isprime(n):
|
||||
|
||||
def solution(n):
|
||||
"""Returns the n-th prime number.
|
||||
|
||||
|
||||
>>> solution(6)
|
||||
13
|
||||
>>> solution(1)
|
||||
@ -58,4 +52,4 @@ def solution(n):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(solution(int(raw_input().strip())))
|
||||
print(solution(int(input().strip())))
|
||||
|
Reference in New Issue
Block a user