Roots of unity: Difference between revisions

m (→‎{{header|REXX}}: added whitespace, simplified code, optimized two functions.)
Line 339:
=={{header|Crystal}}==
{{trans|Ruby}}
<lang crystalruby>require "complex"
 
def roots_of_unity(n)
Line 348:
</lang>
Or alternative
<lang crystalruby>
def roots_of_unity(n)
(0...n).map { |k| Complex.new(Math.cos(2 * Math::PI * k / n), Math.sin(2 * Math::PI * k / n)) }
Anonymous user