project Euler第三题

来源:互联网 发布:百度软件中心手机 编辑:程序博客网 时间:2024/05/09 19:01


题目:

The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?

算法:

#!/usr/bin/env python#coding=utf-8a = 600851475143b = 0Li = 3Lwhile i < a:    i += 2    if a%i == 0:        a = a/i        b = b if b>i else i        i -= 2print b

结果:

6857