OFFSET
1,2
COMMENTS
Numbers with 21 digits cannot fit every number from 0 to 20 as strings. Hence this sequence cannot have any numbers with 21 digits or more, making it finite.
1918171615141312110 is the largest number in this sequence (see examples).
EXAMPLE
Consider x = 40312. f(0) = 1, f(1) = 3, f(3) = 2, f(2) = 4, f(4) = 0 and so we have visited every index of x.
Consider the largest number in this sequence, x = 1918171615141312110. f(0) = 18, f(18) = 2, f(2) = 15, f(15) = 8, f(8) = 3, f(3) = 13, f(13) = 12, f(12) = 14, f(14) = 10, f(10) = 17, f(17) = 4, f(4) = 11, f(11) = 16, f(16) = 6, f(6) = 7, f(7) = 5, f(5) = 9, f(9) = 1, f(1) = 0 and so we have visited every index of x.
MATHEMATICA
{{0}}~Join~Array[Block[{k = #, r}, r = Range[0, k]; FromDigits /@ Select[DeleteCases[Permutations[r, {k + 1}], _?(First@ # == 0 &)], With[{w = #}, Union@ Rest@ Nest[Append[#, Position[w, #[[-1]]][[1, 1]] - 1] &, {0}, Length@ w] == r] &]] &, 4] // Flatten (* Michael De Vlieger, Apr 21 2019 *)
CROSSREFS
KEYWORD
nonn,fini,base
AUTHOR
Dmitry Kamenetsky, Apr 18 2019
STATUS
approved