# user_number = int(raw_input("Please enter a number less than or equal to 1,000 "))
# sum = 0
# for i in range(0,1001):
#     if i%3 == 0 or i%5 == 0:
#         sum += i
# print sum 

# sum = 0
# for i in range(0, 4000000, 3):
#         if (i % 2 == 0):
#                 sum += i
# print sum 

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

# fib1 = 1
# fib2 = 1
# sum = 0
# user_num = int(raw_input("Select a number "))
# for i in range(0, user_num):
#         if(fib1 % 2 == 0):
#                 sum += fib1
#         #figure out next number
#         temp = fib1 + fib2 #stash value in temp
#         fib1 = fib2 #previous 2 now 1
#         fib2 = temp #temp is new value 2
# print sum 

# # Khanh and crew
# fibSeq = [0, 1]
# i = 1
# sum = 0
# while fibSeq[-1] < 4000000:
#    fibSeq.append(fibSeq[i] + fibSeq[i - 1])
#    i += 1
# del fibSeq[-1]
# print fibSeq
# for i in fibSeq[1:len(fibSeq)]:
#    if i % 2 == 0:
#        sum += i
# print sum
        
# The prime factors of 13195 are 5, 7, 13 and 29.

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

# num = 13195
# prime = []
# for i in range(2,13195):
#         if 13195 % i == 0:
#                 prime.append(i)
#                 num == num / i 
#                 i = 2
# print prime  

#begin Sean code

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

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

# prime numbers are only divisble by 1 and itself

# user_num = int(raw_input("What number do you want to test? "))

# prime_factors = []

# for i in range (2,user_num):
#     if (user_num % i == 0):
#         prime_factors.append(i)
#         user_num = (user_num / i)
# print prime_factors

#2 and 3 always prime
known_primes = [2,3]
#a funtionthat will find if a number is prime
def is_prime(n):
        print n 
        total_known_primes = len(known_primes)
        for i in range(0, total_known_primes):
                if(n % known_primes[i] == 0):
                        #this is divisible by a prime numer so it CANNOT be prime 
                        return False
        else: 
                #its not divisible by this one... but that doesnt mean it's not prime
                #it's just not divisible by this number, but need to check next known prime in sequence, and so on 
                continue 
#we went through all known primes, and never hit our return False...
# which means this wasnt devisible by a known prim,
# so it must be prime: append
known_primes.append(n)
if (i == total_known_primes):
        return True                 

print is_prime(6) #return False
print is_prime(8) #return False
print is_prime(9) #return Flase
