For Lovelock gravity,
$$
L=R_{a_{2}b_{2}}^{c_{2}d_{2}}\cdots R_{a_{m}b_{m}}^{c_{m}d_{m}}\delta_{c_{2}d_{2}\cdots c_{m}d_{m}}^{a_{2}b_{2}\cdots a_{m}b_{m}}
$$
where
$$
\delta_{{jc_{1}d_{1}...c_{m}d_{m}}}^{{ia_{1}b_{1}...a_{m}b_{m}}}=\det\left[\begin{array}{c|ccc}\delta_{j}^{i} & \delta_{{c_{1}}}^{i} & \cdots & \delta_{{d_{m}}}^{i}\\hline \\delta_{j}^{{a{1}}}\\vdots & & \delta_{{c_{1}d_{1}...c_{m}d_{m}}}^{{a_{1}b_{1}...a_{m}b_{m}}}\\delta_{j}^{{b\{m}}}\end{array}\right]
$$
when $m=2$, we get Einstein gravity; when $m=3$, we get Gauss-Bonnet gravity. But how to deal with it more generally? More concretely, I don't know how to do it use for
loop.