# If 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.

# Answer: 233168

 

# =============================================================
# # multiples = []
# # for i in range(0, 1000):
# #     if i % 3 == 0 or i % 5 == 0:
# #         multiples.append(i)
# # print sum(multiples)
# ############################################

# Each 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, find the sum of the even-valued terms.

# Answer: 4613732
# # list_Fibo = [1,2]
# # while list_Fibo[len(list_Fibo)-1] <= 4000000:
# #     list_Fibo.append(list_Fibo[len(list_Fibo) - 1] + list_Fibo[len(list_Fibo) - 2])
# # #while loop stops AFTER the last number in the
# # #list is less than 4 millions
# # list_Fibo.pop()
# # even_list_F = []
# # sum = 0
# # for i in list_Fibo:
# #     if i % 2 == 0:
# #         sum += i
# # print sum
# #################################################


# Option 3:

# The prime factors of 13195 are 5, 7, 13 and 29.

# What is the largest prime factor of the number 600851475143 ?

# Answer: 6857
# ########################
# ##  not finished code ##
# ########################
# # x = 600851475143
# # x1 = 500000
# # list_factors_x = []
# # for i in xrange(1, int(x/2)):
# #     if x % i == 0:
# #         list_factors_x.append(i)

# # #list of lists of factors of factors to list_factors_x
# # lists_factorsss_x = []
# # for i in range(len(list_factors_x)-1):
# #     lists_factorsss_x.append([])
# #     for j in xrange(2,list_factors_x[i]+1):
# #         if list_factors_x[i] % j == 0:
# #             lists_factorsss_x[i].append(j)

# # #create list of lists of factors of prime numbers
# # list_factors_prime = []
# # for i in lists_factorsss_x:
# #     if len(i) == 2:
# #         list_factors_prime.append(i[1])
# # print list_factors_prime[len(list_factors_prime) - 1]

###############################
# the best solution#
##########################
x = 600851475143
flag = True
while flag:
    for i in xrange(2, x):
        if x % i == 0:
            x = x/i
            break
        elif i == x - 1:
            flag = False
print x
    