Vyxal l
, 6 5 bytes
≬K¯÷ẋ
This is the same as the 6 byte answer below except the length is taken by the l
flag rather than a L
element.
Vyxal, 7 6 bytes
≬K¯÷ẋL
≬ # 3-element lambda:
K # Push a list of the divisors, from 1 to the number itself in increasing order
¯ # Deltas - returns a list of the consecutive differences in the list.
# The resulting list has a length of 1 less than the one fed to it.
÷ # Unwrap the list onto the stack. For a non-empty list, this is effectively
# equivalent to t (Tail - get the last item). But for an empty list, the
# result is effectively whatever was already on the stack, i.e. the the
# number whose list of divisors was taken, i.e., 1, the only one that yields
# an empty deltas list. This makes 1, instead of 0, the fixed point.
ẋ # Repeat the lambda on the number at the top of the stack (which is initially
# the input) until the result no longer changes, returning a list of the
# results. The last result will be 1, our fixed point.
L # Length
This is very slow for most numbers of more than 60 decimal digits or so, since it has to generate a full list of divisors (even if it only uses the largest two). Prime factorization is still fast enough at that level, but unless the number has only one distinct prime factor, the list of divisors will be orders of magnitude longer.