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

def algorithm1():
    sum = 0
    for i in range(1, 1000):

        if i % 3 == 0 or i % 5 ==0:
            sum += i

    print sum
algorithm1()




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

def algorithm2():
    sum = long(0)   
    n = 200
    a, b = 1, 1
    for i in range(n - 1):
        a, b = b, a + b
        if a % 2 == 0:

            sum += a
        if a > 4000000:
            break

    return sum
print algorithm2()







def algorithm3():

    i = 1
    while i < 600851475143:
        if 600851475143%i == 0:
            a = 600851475143/i

            value = 3

            while value < a:
                if a % value == 0:
                    break
                if value > a/2:

                    return a
                value += 2

        i += 2

print algorithm3()

# def the_sieve():
#     prime_list = [2,3]
#     for i in range(41000000):
#         for j in prime_list:
#             if i % j == 0:
#                 # this number is divisible by a known prime
#                 # it CANNOT be prime
#                 not_prime = True
#             # we know this number isnt divisible by any known prime
#         prime_list.append(i)
