Skip to content

Instantly share code, notes, and snippets.

@sakadonohito
Created December 8, 2013 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakadonohito/7856455 to your computer and use it in GitHub Desktop.
Save sakadonohito/7856455 to your computer and use it in GitHub Desktop.
パスカルの三角形?
#!/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