Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Created January 18, 2014 14:20
Show Gist options
  • Save ph3nx/8491227 to your computer and use it in GitHub Desktop.
Save ph3nx/8491227 to your computer and use it in GitHub Desktop.
Ruby program that prints a multiplication table for numbers up to your input. For example 12 x 12 fields.
def tbl max
for y in (1..max) do
for x in (1..max) do
sol = y*x
if sol < 10
print "#{sol} "
elsif sol < 100
print "#{sol} "
else
print "#{sol} "
end
end
print "\n"
end
end
@mlyubarskyy
Copy link

print (x*y).to_s.center(5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment