The article below is just that. A note for yourself.
reference) https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
def make_divisors(n):
"""
Function to enumerate divisors
Example) n = 100
⇒ 100 = 1 * 100, 2 * 50, 4 * 25, 5 * 20, 10 * 10
⇒ 1, 2, 4, 5,Look up to 10 and the pair(n // i)To list(n /i float)
⇒ 10 *Avoid duplication like 10&
"""
divisors = []
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
Recommended Posts