mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-01 00:41: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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user