RosettaCodeData/Task/Roots-of-unity/MiniScript/roots-of-unity.mini
2023-07-01 13:44:08 -04:00

15 lines
398 B
Text

complexRoots = function(n)
result = []
for i in range(0, n-1)
real = cos(2*pi * i/n)
if abs(real) < 1e-6 then real = 0
imag = sin(2*pi * i/n)
if abs(imag) < 1e-6 then imag = 0
result.push real + " " + "+" * (imag>=0) + imag + "i"
end for
return result
end function
for i in range(2,5)
print i + ": " + complexRoots(i).join(", ")
end for