Skip to content

Instantly share code, notes, and snippets.

@WizardNinja
Created September 24, 2013 18:50
Show Gist options
  • Select an option

  • Save WizardNinja/6689462 to your computer and use it in GitHub Desktop.

Select an option

Save WizardNinja/6689462 to your computer and use it in GitHub Desktop.
multiplication table exer. this version formats the numbers correctly using some fancy formatting stuff I found on google.
puts "Exersize: 1"
#Write a program that prints out the answers of a 9 x 9 multiplication table
for x in (1..9)
for y in (1..9)
answer = x * y
print "%-3d " % answer
end
puts
end
puts
puts "Exersize: 2"
#Write a program that finds the largest power of 3 less than 10,000
num = 3
answer = 0
while num < 10_000
answer = num
num = num * 3
end
puts "#{answer} is the highest power of 3 less than 10,000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment