Ruby program to print multiplication table of a number

bookmark

=begin
Ruby program to print multiplication table of 
a number(by using for loop)
=end

puts "Enter the number:"
num=gets.chomp.to_i

for i in 1..10
    mult=num*i
    puts "#{num} * #{i} = #{mult}"
end

 


Output:

Enter the number:
13
13 * 1 = 13
13 * 2 = 26
13 * 3 = 39
13 * 4 = 52
13 * 5 = 65
13 * 6 = 78
13 * 7 = 91
13 * 8 = 104
13 * 9 = 117
13 * 10 = 130