The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
def problem3(n): ''' The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number n ? ''' result = 0 #store the largest prime #All primes are odd except 2 if n % 2 == 0: result = 2 n /= 2 i = 3 while n != 1: if n % i == 0: result = i n /= i i += 2 return result
0 nhận xét:
Đăng nhận xét