首页 > 代码库 > Euler Project question 15 in python way
Euler Project question 15 in python way
# This Python file uses the following encoding: utf-8
# Starting in the top left corner of a 2×2 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 20×20 grid?
# pictures see at https://projecteuler.net/problem=15
import time
start = time.time()
def factorial(n):
sum = 1
for i in range(2, n+1):
sum *= i
return sum
print "%s ways ways found in %s seconds" % (factorial(40)/(factorial(20)*factorial(20)), time.time() - start)
Euler Project question 15 in python way
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。