RosettaCodeData/Task/Square-but-not-cube/Ruby/square-but-not-cube-2.rb
2023-07-01 13:44:08 -04:00

4 lines
165 B
Ruby

squares = Enumerator.new {|y| 1.step{|n| y << n*n} }
puts "Square cubes: %p
Square non-cubes: %p" % squares.take(33).partition{|sq| Math.cbrt(sq).to_i ** 3 == sq }