Created
September 24, 2013 18:50
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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