Home>

I want to display the calculation result in Ruby vertically.

puts 50 * 50

Result: 2500

I want to make it vertical instead of horizontal.

Result:
2
5
0
0
I want to

Thank you.

  • Answer # 1

    puts (50 * 50) .to_s.chars.join ("\ n")

  • Answer # 2

    (50 * 50) .to_s .each_char {| c | puts c}

  • Answer # 3

    puts (50 * 50) .to_s.chars