mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts] fix factors function in pycalc
This commit is contained in:
parent
87c8dc8113
commit
6a4b9beaca
1 changed files with 3 additions and 4 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue