OFFSET
1,3
COMMENTS
Theorem: Every nonnegative number appears.
Proof: (Sketched by Enrique Navarrete, Sep 25 2018; completed by N. J. A. Sloane, Oct 27 2018)
(i) Sequence is infinite (dG, G=giant number, is always available)
(ii) As usual for these "lexicographically earliest distinct term sequences", for any k, there is a threshold n_k such that for all n > n_k, a(n) > k.
(iii) Some final digit (d, say) appears infinitely often. (Otherwise sequence would be finite.) If d=0, go to step (vi).
(iv) All numbers beginning with d appear (If dm were missing, find xd in sequence which is > dm and also > n_{dm}. Then term after xd would be dm, contradiction.)
(v) In particular, all numbers dm0 appear.
(vi) After a number ending in 0, the next number is the smallest missing number. So if x is missing, find dm0 > n_x, then the next term would be (0)x = x, a contradiction. QED
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
EXAMPLE
a(2) = 1 since it is formed from a(1) = 0 as 01 = 1.
a(20) = 11 since it is the smallest number not yet in the sequence that starts with the ending digit 0 of a(19) = 90.
MATHEMATICA
Nest[Append[#, Block[{k = 1}, While[Nand[FreeQ[#, k], If[# == 0, True, First@ IntegerDigits@ k == #] &@ Mod[#[[-1]], 10]], k++]; k]] &, {0}, 69] (* Michael De Vlieger, Oct 15 2018 *)
PROG
(PARI) nexta(v, x) = {my(d = x % 10, newa); for (i=0, oo, newa = eval(concat(Str(d), Str(i))); if (! vecsearch(v, newa), return (newa)); ); }
lista(nn) = {lasta = 0; print1(lasta, ", "); va = [lasta]; for (n=1, nn, newa = nexta(va, lasta); print1(newa, ", "); va = vecsort(concat(va, newa)); lasta = newa; ); } \\ Michel Marcus, Oct 15 2018
CROSSREFS
AUTHOR
Enrique Navarrete, Sep 25 2018
STATUS
approved