标签:python
Euler 14的不同解法 ----所涉及的知识 1. yield 2.BF 3. decorator 4.cache 5.等等
def euler_problem_14():
"""print("value : %s terms: %s" % (value, terms))
def ext15(n):
if n > 1:
yield n
if n % 2 == 0:
n /= 2
for i in ext15(n):
yield i
else:
n = 3 * n + 1
for i in ext15(n):
yield i
else:
yield n
def count12():
count = 0
count1 = 0
for i in xrange(200000):
for k, j in enumerate(ext15(i)):
count1 = k
if count1 > count:
(count1, count) = (count, count1)
print count
Euler_problem_14 for python,布布扣,bubuko.com
标签:python
原文地址:http://blog.csdn.net/zouyee/article/details/27204829