Skip to content

Instantly share code, notes, and snippets.

@rubyginner
Created October 11, 2012 05:27
Show Gist options
  • Save rubyginner/3870392 to your computer and use it in GitHub Desktop.
Save rubyginner/3870392 to your computer and use it in GitHub Desktop.
Generate a multiplication table
# version 1
(1..10).each { |y|
(1..10).each { |x|
print "#{x * y} "
}
puts ''
}
# version 2
def multiply(m,n)
(1..n).each do |x|
o = ''
(1..m).each do |y|
o += (x*y).to_s + ' '
end
puts o
end
end
multiply(10,10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment