euler/euler015.rb

17 lines
210 B
Ruby
Raw Normal View History

def factorial(n)
i = 1
while (n > 0)
i *= n
n -= 1
end
i
end
def combination(n, k)
factorial(n) / (factorial(k) * factorial(n-k))
end
def lattice_paths(size)
combination(2*size, size)
end