Jelly, 9 bytes, slow
DUḌ⁵%
’Ç¿
’Ç¿ Decrement input while…
DUḌ The number with digits reversed (12300 → 321)
⁵% is not a divisor of 10 (10 % n is truthy).
Jelly, 11 bytes, fast
This uses the fact that mapping \$[1 \dots 9]\$ to \$[1,2,2,2,2,5,5,5,5,5]\$ is achieved by $$ n \mapsto \max_{1 \leq k \leq n} \gcd(k, 10). $$
DḢRg⁵ṀṁDŻIḌ
DḢR range [1..first digit]
g⁵ gcd each with 10
Ṁ maximum
ṁD reshape like original digits (e.g. [2,2,2,2,2])
ŻI prepend 0, get increments (e.g. [2,0,0,0,0])
Ḍ digits to number
This uses the fact that mapping \$[1 \dots 9]\$ to \$[1,2,2,2,5,5,5,5,5]\$ is achieved by $$ n \mapsto \max_{1 \leq k \leq n} \gcd(k, 10). $$
Porting xnor's 5>>5/-~n
formula is six bytes ‘5:5æ»
, but the above is only four Rg⁵Ṁ
.