OFFSET
1,2
COMMENTS
"Lexicographically earliest" means that the sequence is constructed by choosing a(n) to be the smallest positive integer not leading to a contradiction; "injective" means that a number may occur only once, and is thereafter excluded from the possible choices for subsequent terms.
Open problems: (1) Prove that a(n) > n for all n > 9.
(2) Prove that the subsequence of terms not ending in "9" is strictly increasing.
(3) Prove the given formula for a(n).
(4) Find an explicit formula for indices n where a(n) = m*10^k - 1.
LINKS
M. F. Hasler, Table of n, a(n) for n=1..999
Eric Angelini, a(n) is the digitsum of a(a(n)), November 2009.
Eric Angelini, a(n) is the digitsum of a(a(n)) [Cached copy, with permission]
FORMULA
If n < 10 or n is in { a(1), ..., a(n-1) }, then a(n) = (n mod 9 + 1)*10^floor(n/9) - 1 (= n for n < 10).
Otherwise, a(n) = n+1 unless n+1 occurred earlier in the sequence (and therefore is of the form k*10^m - 1), in which case a(n) = n+2 (conjectured).
PROG
(PARI) /* This code is for illustration and "experimental verification"; several important simplifications could be made to compute a(n) efficiently. */
A167152(n, output=0, u=[])={ my(a=vector(n), k); for( i=1+#u, #a, if( setsearch( u, i )
, /* this index has already appeared, so this a(n) must have that digit sum */
k= ((i % 9)+1)*10^(i\9)-1; /* this k is the smallest number with digit sum i; this should work "at once" and the loop below should not be needed */
while( sumdigits(k) != i || setsearch(u, k), k+=10^(i\9-1)*9 /*e.g. to 89 we add 9*/)
, /* index has not yet appeared: choose smallest number not yet used and not leading to contradiction */
/* is it possible that a[i] = k < i ? Clearly a[i] = i iff i <= 9, else digsum(i)<i. */
k=1; while( setsearch(u, k) || (k<=i & sumdigits(if( k<i, a[k], i)) != k), k++);
)/*end if i in u */;
output & if( #output>1, write(output, i" "k), print1(k, ", ")); u=setunion( u, Set(a[i]=k))
)/* end for i */; k}
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Eric Angelini and M. F. Hasler, Nov 02 2009
EXTENSIONS
Edited by Charles R Greathouse IV, Aug 02 2010
STATUS
approved