Task

Show the first   30   positive integers which are squares but not cubes of such integers.

Optionally, show also the first   3   positive integers which are both squares and cubes,   and mark them as such.




var square_and_cube = Enumerator({|f|
    1..Inf -> each {|n| f(n**6) }
})
 
var square_but_not_cube = Enumerator({|f|
    1..Inf -> lazy.map {|n| n**2 }.grep {|n| !n.is_power(3) }.each {|n| f(n) }
})
 
say "First 30 positive integers that are a square but not a cube:"
say square_but_not_cube.first(30).join(' ')
 
say "First 15 positive integers that are both a square and a cube:"
say square_and_cube.first(15).join(' ')