def calculate_bin(memory):
    """Calculates the memory bin (EC2 Instance type) according to the amount of memory in gigabytes needed to process the job."""
    if memory < 1.792:
        mem_bin = 0
    elif memory < 7.168:
        mem_bin = 1
    elif memory < 14.336:
        mem_bin = 2
    elif memory >= 14.336:
        mem_bin = 3
    else:
        mem_bin = "nan"
    return mem_bin