# ch8ex7_goldbachc
"""Has the find_prime_summands(n) and its supporting functions."""

from math import sqrt, floor

def find_prime_summands(n):
    """Find two primes that add up to n.

    Parameters:
    n - even natural number"""
    if n % 2 == 1:
        return None, None

    prime = 1
    for i in range(n//2):
        if is_prime(n-prime):
            return prime, n-prime
        prime = next_prime(prime)

    print("An error occured. Couldn't find two primes adding to ", n)

def is_prime(n):
    """Returns True if n is a prime number, False otherwise."""
    for divisor in range(2, floor(sqrt(n)) + 1):
        if n % divisor == 0:
            return False
    return True

def next_prime(n):
    """Returns the next prime number after n."""
    while True:
        n += 1
        if is_prime(n):
            return n

# ch8ex7_goldbachc
"""Has the find_prime_summands(n) and its supporting functions."""

from math import sqrt, floor

def find_prime_summands(n):
    """Find two primes that add up to n.

    Parameters:
    n - even natural number"""
    if n % 2 == 1:
        return None, None

    prime = 1
    for i in range(n//2):
        if is_prime(n-prime):
            return prime, n-prime
        prime = next_prime(prime)

    print("An error occured. Couldn't find two primes adding to ", n)

def is_prime(n):
    """Returns True if n is a prime number, False otherwise."""
    for divisor in range(2, floor(sqrt(n)) + 1):
        if n % divisor == 0:
            return False
    return True

def next_prime(n):
    """Returns the next prime number after n."""
    while True:
        n += 1
        if is_prime(n):
            return n

# ch8ex7_goldbachc Has the find_prime_summands(n) and its supporting functions. Find two primes that add up to n.      Parameters:     n - even natural number Returns True if n is a prime number, False otherwise. Returns the next prime number after n.