示例#1
0
def sum_primes(n):
    sum = 2
    i = 3
    while(i < n):
        if eulerhelp.is_prime(i):
            sum += i
        i += 2
    return sum
示例#2
0
def nth_prime(n):
    i = 1
    number = 3
    while True:
        if eulerhelp.is_prime(number):
            i += 1
            if i == n:
                return n, number
        number += 2
示例#3
0
def largest_prime_factor(n):
    if eulerhelp.is_prime(n):
        # prime_factors.append(n)
        return n, prime_factors
    if n % 2 == 0:
        # prime_factors.append(2)
        return largest_prime_factor(n // 2)
    i = 3
    while True:
        if n % i == 0:
            # prime_factors.append(i)
            return largest_prime_factor(n // i)
        else:
            i += 2