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())))
|
||||
|
@ -6,14 +6,6 @@ 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
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
|
||||
def isprime(number):
|
||||
for i in range(2, int(number ** 0.5) + 1):
|
||||
if number % i == 0:
|
||||
@ -23,7 +15,7 @@ def isprime(number):
|
||||
|
||||
def solution(n):
|
||||
"""Returns the n-th prime number.
|
||||
|
||||
|
||||
>>> solution(6)
|
||||
13
|
||||
>>> solution(1)
|
||||
@ -73,4 +65,4 @@ def solution(n):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(solution(int(raw_input().strip())))
|
||||
print(solution(int(input().strip())))
|
||||
|
@ -6,15 +6,9 @@ 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
|
||||
import math
|
||||
import itertools
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
|
||||
def primeCheck(number):
|
||||
if number % 2 == 0 and number > 2:
|
||||
@ -32,7 +26,7 @@ def prime_generator():
|
||||
|
||||
def solution(n):
|
||||
"""Returns the n-th prime number.
|
||||
|
||||
|
||||
>>> solution(6)
|
||||
13
|
||||
>>> solution(1)
|
||||
@ -50,4 +44,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