Last active
August 29, 2015 14:26
-
-
Save Yorgg/049e0c6bffa02b77f400 to your computer and use it in GitHub Desktop.
Multiplication table in ruby
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
#Multiplication table in Ruby with nested arrays | |
#[[1, 2, 3, 4], | |
# [2, 4, 6, 8], | |
# [3, 6, 9, 12], | |
# [4, 8, 12, 16]] | |
def multiplication_table(size) | |
Array.new(size) {|n| n+=1}.map do |row| | |
Array.new(size) {|col| col+=1; row*col} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment