摘要: Problem 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? 13195的素因子为 5,7,13和29. 求600851475143的最大素因子.本题考的是分解因式. 用factor取 2 以及比2大的奇数(素数集合的父集) 除n,直到 factor2>n,如果n不等于1,因为n不能被小于n的平方根整除,则n为素数.def factors(n): factor=2 while factor**2<=n: 阅读全文
posted @ 2011-04-14 12:51 class 阅读(377) 评论(1) 推荐(0) 编辑
摘要: Problem 2: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the 阅读全文
posted @ 2011-04-07 17:45 class 阅读(951) 评论(0) 推荐(0) 编辑
摘要: 前段时间大家的推荐找到了 Peoject Euler这个联系算法的网站,很有收获,和大家分享一下做题的经验。Problem 1:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.如果我们列出那些是3或5的倍数的小于10的自然数,我们得到了 3 ,5,6 以及 9.这些数的和为 23 阅读全文
posted @ 2011-04-02 11:53 class 阅读(1282) 评论(1) 推荐(0) 编辑