Euler project 53
#-*- coding:utf-8 -*- from datetime import datetime def Comb(n, r, list): return list[n]/(list[n-r] * list[r]) def Euler53(): list = [1, 1] for x in xrange(2,101): list.append(x * list[-1]) counter = 0 for i in xrange(23, 101): for j in xrange(1, i + 1): if Comb(i, j, list) > 1000000: counter += 1 return counter def main(): start = datetime.now() answer = Euler53() end = datetime.now() print end - start, answer if __name__ == "__main__": main()
#実行結果 0:00:00.005747 4075