1. The problem statement, all variables and given/known data The problem is taken straight from the Project Euler website: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? The answer is 6857 as I must have solved it before but I can't figure out how I worked it out. 2. Relevant equations 3. The attempt at a solution Code (Text): from math import * number = 600851475143 number_sqrt = sqrt(number) i = 1 j = 2 highest_prime_factor = 0 while i < number_sqrt: #Loops while i is less than the square root of number if number % i == 0: #Tests if i is a factor of number while j <= sqrt(i): #Loops while j is less than square root of i is_prime = 1 if i % j == 0: #Tests if i is prime is_prime = 0 break if j == trunc(sqrt(i)) and is_prime == 1: #Checks if loop is finished and if i is prime highest_prime_factor = i #Sets variable for highest prime factor as i j += 1 i += 1 print highest_prime_factor I'm not sure what wrong with my code but it seems to be printing the highest factor of the number.