def is_prime(val):
    """ simple check for a prime value.
        Note: as a function called several time it is expensive. """
    if val <= 1:
        return False
    if val == 2:
        return True
    if val % 2 == 0:
        return False

    for divisor in range(3, int(math.sqrt(val))+1, 2):
        if val % divisor == 0:
            return False

    return True
 simple check for a prime value.
        Note: as a function called several time it is expensive. 
recipes/Python/577329_Some_prime_generation_algorithms/recipe-577329.py