摘要:
题目14:找出以100万以下的数字开始的最长序列。以下迭代序列定义在整数集合上:nn/2 (当n是偶数时)n3n+ 1 (当n是奇数时)应用以上规则,并且以数字13开始,我们得到以下序列:134020105168421可以看出这个以13开始以1结束的序列包含10个项。虽然还没有被证明(Collatz问题),但是人们认为在这个规则下,以任何数字开始都会以1结束。以哪个不超过100万的数字开始,能给得到最长的序列?注意:一旦序列开始之后,也就是从第二项开始,项是可以超过100万的。3n+1问题。View Code 1 maxn = 1000000 2 length = [0 for i in ra 阅读全文
摘要:
Problem 13Work out the first ten digits of the sum of the following one-hundred 50-digit numbers....(100个50位数)...为了避免有后面低位进位的情况,取了每个50位数的前13位来运算。1 def pe013BF():2 data = open('013.txt', "r")3 sum1 = str(sum([int(line[:13]) for line in data]))[:10]4 return sum15 6 if __name__ == 阅读全文
摘要:
Problem 12The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...Let us list the factors of the first seven triangle numbers:1: 13: 1,36: 1,2, 阅读全文