Sample Program

def multiples(n)
for i in 1..n
product = (n * i).to_s
spaces = " " * (4 - product.length)
yield spaces + product
end
" "
end
  1. Print triangular multiplication table
for i in 1..10
puts multiples(i) { |arg| print arg }
end