mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Merge pull request #270 from cclauss/patch-5
xrange() was removed in Python 3 in favor of range()
This commit is contained in:
commit
5e21232e82
|
@ -1,6 +1,12 @@
|
|||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
|
||||
try:
|
||||
xrange # Python 2
|
||||
except NameError:
|
||||
xrange = range # Python 3
|
||||
|
||||
|
||||
def is_prime(n):
|
||||
for i in xrange(2, int(sqrt(n))+1):
|
||||
if n%i == 0:
|
||||
|
@ -30,4 +36,4 @@ if __name__ == '__main__':
|
|||
n = int(sys.argv[1])
|
||||
print(sum_of_primes(n))
|
||||
except ValueError:
|
||||
print('Invalid entry - please enter a number.')
|
||||
print('Invalid entry - please enter a number.')
|
||||
|
|
Loading…
Reference in New Issue
Block a user