[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):
result = set()
for i in range(1, int(sqrt(n)) + 1):
div, mod = divmod(n, i)
if mod == 0:
result.add(div)
result.add(mod)
if n % i == 0:
result.add(i)
result.add(n // i)
return result