Roots of unity: Difference between revisions

Content deleted Content added
Line 447: Line 447:
<lang haskell>import Data.Complex
<lang haskell>import Data.Complex


rootsOfUnity n = [cis (2*pi*k/n) | k <- [1..n]]</lang>
rootsOfUnity n = [cis (2*pi*k/n) | k <- [0..n-1]]</lang>


Output:
Output:
<lang haskell>*Main> rootsOfUnity 3
<lang haskell>*Main> rootsOfUnity 3
[1.0 :+ 0.0,
[(-0.4999999999999998) :+ 0.8660254037844387,
(-0.5000000000000004) :+ (-0.8660254037844384),
(-0.4999999999999998) :+ 0.8660254037844387,
1.0 :+ (-2.4492127076447545e-16)]</lang>
(-0.5000000000000004) :+ (-0.8660254037844384)]</lang>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==