| 1 | initial version |
The solution seems to be to shift the problem to complex numbers and then use QQbar.
def Omega(m, lng) -> list[int]:
L = LazyLaurentSeriesRing(QQbar, 'x')
x = L.gen()
if m == 0: return [L(0^n) for n in (0..lng)]
w = QQbar(exp(2 * pi * I / m))
f = sum(exp(x * w**j) for j in range(m)) / m
return [round(real(factorial(n)*f.coefficient(n))) for n in (0..lng)]
for m in (0..6): print(Omega(m, 24))
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.