Skip to content

Instantly share code, notes, and snippets.

@ETBlue
Created February 19, 2013 01:38
Show Gist options
  • Save ETBlue/4982363 to your computer and use it in GitHub Desktop.
Save ETBlue/4982363 to your computer and use it in GitHub Desktop.
# header
puts "\n--------------------------\n * Multiplication Table * \n--------------------------"
# body
(1..9).each{|y|
# one row
(1..9).each{|x|
number=x*y
# ternary operator for alignment
print number<10 ? " #{number} ":"#{number} "
}
# newline after one row
print "\n"
}
# footer
puts "--------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment