예제 #1
0
def primeFactors(n):
    """a list of prime factors of n"""

    result = []    
    upper_bound = 1 +int(n**0.5) # only have to seek to the square root 
    searchList = primes(upper_bound)
    
    for divisor in searchList:
        if divides(divisor, n):
            result.append(divisor)
            result += primeFactors(int(n // divisor))
            break
    # no factors found, so assume prime.
    if result == []:
        result.append(n)
    return result
예제 #2
0
파일: p1.py 프로젝트: djuber/project-euler
def euler_p1():
    return sum(filter(lambda x: divides(3,x) or divides(5,x), range(1000)))