Problem 4 of the 2025 International Mathematical Olympiad asked (paraphrased):
Let \$f(n)\$ be the sum of the largest three proper divisors of \$n\$, that is divisors excluding \$n\$ itself. For example, \$f(24) = 6 + 8 + 12 = 26\$. Repeatedly apply \$f\$ until you cannot because your current value has fewer than 3 proper divisors. For which starting values of \$n\$ does this process continue forever?
For example, 24 does not work because it gives $$ 24 \to 26 \to 16 \to 14 \to 10 \to 8 \to 7 $$ and 7 has only the proper divisor 1. But, 6 works because it just goes \$ 6 \to 6 \to 6 \to \cdots\$.
These values are OEIS A386276, which starts:
6, 18, 42, 54, 66, 72, 78, 102, 114, 126, 138, 162, 174, 186, 198, 216, 222, 234, 246, 258, 282, 294, 306, 318, 342, 354, 366, 378, 402, 414, 426, 438, 462, 474, 486, 498, 504, 522, 534, 546, 558, 582, 594, 606, 618, 642, 648, 654, 666, 678, 702, 714, 726, 738, 762, 774, 786, 792, 798, 822, 834, 846, 858, 864, 882, 894, 906, 918, 936, 942, 954, 966, 978
Given a positive integer \$n\$, output whether the process continues forever, using either:
- One of two fixed distinct values indicating "yes" or "no"
- A truthy or falsy value, as defined by your language (these may be swapped)
The answer to the IMO problem, which you may find useful, is that \$n\$ has the property exactly if its prime factorization
$$ n = 2^{a_2} \cdot 3^{a_3} \cdot 5^{a_5} \cdot 7^{a_7}\cdots $$
satisfies
- \$a_2\$ is odd
- \$a_3 \geq (a_2+1)/2 \$
- \$a_5 = 0 \$
Moreover, these always reach a fixed point -- there are no infinite sequences that reach a cycle or go upwards forever.