Created
December 8, 2013 11:55
-
-
Save sakadonohito/7856455 to your computer and use it in GitHub Desktop.
パスカルの三角形?
This file contains 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
#!/usr/bin/ruby | |
#--*-- coding: utf-8 --*-- | |
num = gets.chomp.to_i | |
num ||= 10 | |
a=[1] | |
num.times{ | |
a=[1]+a.zip(a.slice(1..(a.size))).map{|a,b| a.to_i+b.to_i} | |
p a.join(' ') | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment