get_quotients

ソースコード

from titan_pylib.math.get_quotients import get_quotients

view on github

展開済みコード

 1# from titan_pylib.math.get_quotients import get_quotients
 2def get_quotients(n: int) -> list[int]:
 3    i = 1
 4    a = []
 5    while i * i <= n:
 6        a.append(n // i)
 7        a.append(n // (n // i))
 8        i += 1
 9    a.sort()
10    if not a:
11        return a
12    b = [a[0]]
13    for i in range(1, len(a)):
14        if b[-1] != a[i]:
15            b.append(a[i])
16    return b

仕様

get_quotients(n: int) list[int][source]