Related: Landau's function (OEIS A000793)
Background
Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\cdots,a_i))\$ where \$a_1,a_2,\cdots,a_i\$ is an integer partition of \$n\$.
We can extend this to define "iterations" of Landau's function: let's define \$g_0(n) = 1\$, and \$g_{k+1}(n) = \max(\operatorname{lcm}(g_{k}(n), a_1,a_2,\cdots,a_i))\$ for \$k \ge 0\$. This eventually converges to \$\operatorname{lcm}(1,2,\cdots,n)\$, so we can define "Landau logarithm" to be the smallest value of \$k\$ such that \$g_k(n)=\operatorname{lcm}(1,2,\cdots,n)\$, or equivalently \$g_k(n)=g_{k+1}(n)\$.
The resulting sequence is OEIS A225633.
Illustration
n = 5
To make it clear, let's list up all the integer partitions of 5, which are:
(5)
(4, 1)
(3, 2)
(3, 1, 1)
(2, 2, 1)
(2, 1, 1, 1)
(1, 1, 1, 1, 1)
By definition, \$g_0(5) = 1\$. \$g_1(5)\$ is defined by whatever partition gives the largest LCM, which is \$\operatorname{lcm}(2,3) = 6\$ (which is the same as the plain Landau function). \$g_2(5)\$ is the largest LCM of any partition when combined with 6. We need to find the partition which can give the largest additional factor. Such partition is plain 5, so \$g_2(5) = \operatorname{lcm}(6,5) = 30\$. In the next step, the only partition that boosts the LCM further is (4,1), giving \$g_3(5) = \operatorname{lcm}(30, 4, 1) = 60\$, which is the same as \$\operatorname{lcm}(1, 2, 3, 4, 5)\$. Therefore, the Landau logarithm of 5 is 3.
n = 10
- \$g_0(10) = 1\$
- \$g_1(10) = \operatorname{lcm}(2,3,5) = 30\$
- \$g_2(10) = \operatorname{lcm}(30,7,3) = 210\$
- \$g_3(10) = \operatorname{lcm}(210,8,2) = 840\$
- \$g_4(10) = \operatorname{lcm}(840,9,1) = 2520 = \operatorname{lcm}(1,2,\cdots,10)\$
Therefore the Landau logarithm of 10 is 4.
Challenge
Given a positive integer \$n\$, compute its Landau logarithm.
The shortest code in bytes wins.
Test cases
The first 20 terms (starting at n=1
, up to n=20
inclusive) are:
0, 1, 2, 2, 3, 3, 3, 3, 4, 4,
5, 5, 6, 5, 5, 5, 6, 6, 7, 6