mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts] add factors function for pycalc
This commit is contained in:
parent
85f880db9e
commit
18ddb83d4b
1 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,14 @@
|
||||||
from math import *
|
from math import *
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
print("loaded Python calculator")
|
print("loaded Python calculator")
|
||||||
|
|
Loading…
Reference in a new issue