Comment detail

ピラミッドを作る (Nested Flatten)
さくっと書き上げてみた。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def stars(n)
  2*n-1
end

def pyramid(n)
  1.upto(n) do |i|
    puts(("*"*stars(i)).center(stars(n)))
  end
end
pyramid(10)

Index

Feed

Other

Link

Pathtraq

loading...