I've been working on a problem to find whether or not a given integer n
is a perfect square. Although the algorithm works, I get a MemoryError
. How should I rephrase this code bit?
Thanks in advance.
def is_square(n):
for i in range(1, (n/2)):
i += 1
if n % i == 0 and n // i == i:
return True
return False