[scripts] add factors function for pycalc

This commit is contained in:
Dmytro Meleshko 2019-11-14 19:40:52 +02:00
parent 85f880db9e
commit 18ddb83d4b
1 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,14 @@
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")