Roots of unity: Difference between revisions

m
+D
(→‎{{header|Ada}}: Remove a variable "J" from the calculation of Factor, since it seems to be wrong.)
m (+D)
Line 94:
}
}</cpp>
=={{header|D}}==
{{works with|D|2.012}}
{{works with|D|1.028}}
<d>module nthroots ;
import std.stdio, std.math ;
 
creal[] nthroots(int n) {
creal[] res ;
for(int k = 1 ; k <= n ; k++)
res ~= expi(PI*2*k/n) ;
return res ;
}
void main() {
for(int i = 1; i <= 8 ; i++)
writefln("%2dth : %5.2f", i, nthroots(i)) ;
}</d>
=={{header|Forth}}==
Complex numbers are not a native type in Forth, so we calculate the roots by hand.