Brachylog, 19 16 bytes
-3 thanks to @Unrelated String
Ḋ|⟨ℕ{√₎|/|-}l⟩↰<
A recursive function. If n ≥ 10
, the three operations are tried. For n < 10
we need n
steps to 0
. With this we don't have to check that step(n) ≠ n
, as it only occurs when there is one digit.
Ḋ|⟨ℕ{√₎|/|-}l⟩↰<
Ḋ if n is in 0…9, return n
| otherwise
⟨f h g⟩ [f(n), g(n)] h
ℕ l [n, digits] and n is a natural number
{√₎|/|-} try (root, divide, subtract) one after the other
(results that are not natural numbers will
get filtered in the next step with ℕ)
↰ recurse
< get a number that is strictly larger, thus +1