import math


def nice_num(rge, rnd):
    """
    Get a nice number (1, 2, 5, 10, ...)
    :param rge: range
    :param rnd: round or not
    :return: a nice number
    """
    exponent = math.floor(math.log10(rge))
    fraction = rge / math.pow(10, exponent)

    if rnd:
        if fraction < 1.5:
            nice_fraction = 1
        elif fraction < 3:
            nice_fraction = 2
        elif fraction < 7:
            nice_fraction = 5
        else:
            nice_fraction = 10
    else:
        if fraction <= 1:
            nice_fraction = 1
        elif fraction <= 2:
            nice_fraction = 2
        elif fraction <= 5:
            nice_fraction = 5
        else:
            nice_fraction = 10

    return nice_fraction * math.pow(10, exponent)