#!/usr/bin/env python """ Created on 7 Jan 2018 @author: David Doblas Jiménez @email: daviddoji@pm.me Solution for problem 15 of Project Euler https://projecteuler.net/problem=15 """ from math import factorial from utils import timeit @timeit("Problem 15") def compute(): """ Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20x20 grid? """ n = 20 return int(factorial(2 * n) / (factorial(n) * factorial(2 * n - n))) if __name__ == "__main__": print(f"Result for Problem 15 is {compute()}")