def round2nearestN(x, N=1):
    """Round number :math:`x` to nearest :math:`N`.

    Parameters
    ----------
    x : int or float
        number to round.
    N : int or float
        number to round :math:`x` to.

    Returns
    -------
    int or float
        :math:`x` rounded to nearest :math:`N`.

    """
    if isinstance(N, int):
        return int(N * round(float(x) / N))
    else:
        return N * round(float(x) / N)
