摘要: Largest prime factorProblem 3The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?The answer:import mathdef getLargestPrime(data): list = [] i = 2 while i <= math.sqrt(data): #while i <= data/2: if data%i == 0 : lis... 阅读全文
posted @ 2013-12-10 17:55 tianxiaozz 阅读(141) 评论(0) 推荐(0)
摘要: Even Fibonacci numbersProblem 2Each 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, 阅读全文
posted @ 2013-12-10 16:57 tianxiaozz 阅读(114) 评论(0) 推荐(0)
摘要: Multiples of 3 and 5Problem 1If 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.the direct way the answer :def isMutiple(target, divider1, divider2): if (target % d... 阅读全文
posted @ 2013-12-10 16:38 tianxiaozz 阅读(165) 评论(0) 推荐(0)