码迷,mamicode.com
首页 > 编程语言 > 详细

Euler Project question 15 in python way

时间:2014-10-22 08:43:00      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   for   sp   on   art   bs   ef   

# 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

标签:http   io   ar   for   sp   on   art   bs   ef   

原文地址:http://www.cnblogs.com/cyberpaz/p/4042180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!