import math


def get_sample_size(population_size, confidence_level, confidence_interval):
    """ Returns the approaprate sample size for a population.

    Parameters
    ----------
    population_size: int
        Size of population.
    confidence_level: float
        Confidence Level.
    confidence_interval: float
        Confidence Interval.

    Returns
    -------
    int
        Sample Size

    """
    Z = 0.0  # noqa
    p = 0.5  # noqa
    e = confidence_interval / 100.0  # noqa
    N = population_size  # noqa
    n_0 = 0.0  # noqa
    n = 0.0  # noqa

    confidence_level_constant = (
        [50, 0.67],
        [68, 0.99],
        [90, 1.64],
        [95, 1.96],
        [99, 2.57],
    )

    # LOOP THROUGH SUPPORTED CONFIDENCE LEVELS AND FIND THE NUM STD
    # DEVIATIONS FOR THAT CONFIDENCE LEVEL
    for i in confidence_level_constant:
        if i[0] == confidence_level:
            Z = i[1]  # noqa

    if Z == 0.0:  # noqa
        return -1

    # CALC SAMPLE SIZE
    n_0 = ((Z ** 2) * p * (1 - p)) / (e ** 2)  # noqa

    # ADJUST SAMPLE SIZE FOR FINITE POPULATION
    n = n_0 / (1 + ((n_0 - 1) / float(N)))  # noqa

    return int(math.ceil(n))