def check_commandline_inputs(n, limit):
    """See if the n and limit passed from the command line were valid"""
    try:
        n = int(n)
    except:
        raise ValueError("n wasn't a number")
    valid_ns = [5, 7, 11, 17, 23, 29, 37, 47, 59, 71, 83, 97, 113, 131, 149,
                167, 191, 223, 257, 293, 331, 373, 419, 467, 521]
    if n not in valid_ns:
        raise ValueError("n must be one of: {0}".format(valid_ns))
    try:
        limit = int(limit)
    except:
        raise ValueError("Limit wasn't a number")
    return n, limit