def grubler_f(m, n, j, *f_i):
    """
    Formular (2.4). Grubler's formula for calculation of Degrees of Freedom (DoF) of a mechanism.
    :param m: DoF of a link. For planar mechanisms, m = 3; for spatial mechanisms, m = 6.
    :param n: Number of links.
    :param j: Number of joints.
    :param f_i: DoF brought by joint i. Should be a series of numbers, corresponds to the number of joints.
    :return: DoF of the whole mechanisms.
    """
    dof = m * (n - 1 - j) + sum(f_i)

    return dof