예제 #1
0
def find_smallest_counter():
    curr_comp = 9
    while True:
        primes = [i for i in prime_gen(max_val=curr_comp + 1)]
        if curr_comp not in primes and not any(
                is_square((curr_comp - p) / 2) for p in primes):
            return curr_comp
        curr_comp += 2
예제 #2
0
def find_smallest_counter():
    curr_comp = 9
    while True:
        primes = [i for i in prime_gen(max_val=curr_comp + 1)]
        if curr_comp not in primes and not any(is_square((curr_comp - p)/2)
                for p in primes):
            return curr_comp
        curr_comp += 2
예제 #3
0
def is_triangular(tn):
    '''Leverages:
    The inverse of triangular: n = -1/2 + 1/2 * sqrt(1 + 8 * tn)
    Therefore, 1 + 8 * pn must be square for tn to be triangular.
    Also, since n must be an integer, the evaluated sqrt must be odd
    '''
    special_factor = 1 + 8 * tn
    if is_square(special_factor):
        given_root = int(sqrt(special_factor))
        if given_root % 2 == 1:
            return True
    return False
예제 #4
0
def is_triangular(tn):
    '''Leverages:
    The inverse of triangular: n = -1/2 + 1/2 * sqrt(1 + 8 * tn)
    Therefore, 1 + 8 * pn must be square for tn to be triangular.
    Also, since n must be an integer, the evaluated sqrt must be odd
    '''
    special_factor = 1 + 8 * tn
    if is_square(special_factor):
        given_root = int(sqrt(special_factor))
        if given_root % 2 == 1:
            return True
    return False
예제 #5
0
def is_hexagonal(hn):
    '''Leverages:
    The inverse of hexagonal: n = -1/4 + 1/4 * sqrt(1 + 8 * hn)
    Therefore, 1 + 8 * hn must be square for hn to be hexagonal.
    Also, since n must be an integer, the evaluated sqrt must:
        Have a modulus of 3 with 4
    '''
    special_factor = 1 + 8 * hn
    if is_square(special_factor):
        given_root = int(sqrt(special_factor))
        if given_root % 4 == 3:
            return True
    return False
예제 #6
0
def is_hexagonal(hn):
    '''Leverages:
    The inverse of hexagonal: n = -1/4 + 1/4 * sqrt(1 + 8 * hn)
    Therefore, 1 + 8 * hn must be square for hn to be hexagonal.
    Also, since n must be an integer, the evaluated sqrt must:
        Have a modulus of 3 with 4
    '''
    special_factor = 1 + 8 * hn
    if is_square(special_factor):
        given_root = int(sqrt(special_factor))
        if given_root % 4 == 3:
            return True
    return False
예제 #7
0
def is_pentagonal(pn):
    '''Leverages:
    The inverse of pentagonal: n = 1/6 + 1/6 * sqrt(1 + 24 * pn)
    Therefore, 1 + 24 * pn must be square for pn to be pentagonal.
    Also, since n must be an integer, the evaluated sqrt must:
        Have a modulus of 5 with 6
    '''
    special_factor = 1 + 24 * pn
    if is_square(special_factor):
        given_root = int(sqrt(special_factor))
        if given_root % 6 == 5:
            return True
    return False