[scripts] fix factors function in pycalc

This commit is contained in:
Dmytro Meleshko 2019-11-27 09:32:23 +02:00
parent 87c8dc8113
commit 6a4b9beaca

View file

@ -5,10 +5,9 @@ from fractions import Fraction
def factors(n): def factors(n):
result = set() result = set()
for i in range(1, int(sqrt(n)) + 1): for i in range(1, int(sqrt(n)) + 1):
div, mod = divmod(n, i) if n % i == 0:
if mod == 0: result.add(i)
result.add(div) result.add(n // i)
result.add(mod)
return result return result