Problem 3 - Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
求600851475143的最大素数因子。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 factors = [] 2 maximum = 600851475143 3 def getFactor(x): 4 y = x / 2 5 i = 2 6 while True: 7 if i > y: 8 break 9 if x % i == 0 : 10 factors.append(i) 11 return getFactor(x / i) 12 break 13 i += 1 14 return x 15 16 factors.append(getFactor(maximum)) 17 18 print factors[-1]
posted on 2013-01-06 08:47 luchigster 阅读(128) 评论(0) 编辑 收藏 举报