Exemplo n.º 1
0
def euler010(limit):
    ''' Summation of Primes
    
    The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
    Find the sum of all the primes below two million. 
    
    >>> euler010(10)
    17
    >>> euler010(2000000)
    142913828922L
    '''
    return sum(takewhile(lambda x: x < limit, genprime()))
Exemplo n.º 2
0
def euler007(n):
    ''' 10001st prime
    
    By listing the first six prime numbers: 2, 3, 5, 7, 11,
    and 13, we can see that the 6th prime is 13.

    What is the 10001st prime number?
    
    >>> euler007(6)
    13
    >>> euler007(10001)
    104743
    '''
    return islice(genprime(), n-1, n).next()