login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A165300
a(n) is the smallest number not already present that permits the cyclic repetition of the path 1,2 of the digits in the sequence.
7
1, 2, 12, 121, 21, 212, 1212, 12121, 2121, 21212, 121212, 1212121, 212121, 2121212, 12121212, 121212121, 21212121, 212121212, 1212121212, 12121212121, 2121212121, 21212121212, 121212121212, 1212121212121, 212121212121
OFFSET
1,2
COMMENTS
Conjecture. (1) If n > 1, and a(n) begins and ends with 1, then a(n+1) is obtained by deleting the initial 1 of a(n); (2) if a(n) begins with 1 and ends with 2 then a(n+1) is obtained by adding a final 1 to a(n); (3) if a(n) begins with 2 and ends with 1 then a(n+1) is obtained by adding a final 2 to a(n); (4) if a(n) begins and ends with 2 then a(n+1) is obtained by adding an initial 1 to a(n). This has been confirmed through a(140), which has 71 digits (and should be fairly easy to prove). - John W. Layman, Sep 22 2009
FORMULA
a(n+1) = (1/24)*((a(n) + 10^floor(1 + log_10(a(n))))*(((n-2) mod 4) + ((n-1) mod 4) + 7*(n mod 4) - 5*((n+1) mod 4)) + (10*a(n)+1)*(((n-2) mod 4) + 7*((n-1) mod 4) - 5*(n mod 4) + ((n+1) mod 4)) + (a(n) - 10^floor(log_10(a(n))))*(7*((n-2) mod 4) - 5*((n-1) mod 4) + (n mod 4) + ((n+1) mod 4)) + (10*a(n) + 2)*(-5*((n-2) mod 4) + ((n-1) mod 4) + (n mod 4) + 7*((n+1) mod 4))), with n >= 3 and a(1)=1, a(2)=2. - Paolo P. Lava, Oct 02 2009
EXAMPLE
Starting from 1,2 the next number must be 12 because after 1,2 we shall continue with a 1. But 1 is already in the sequence so we need to add a 2 -> 12. And so on.
MAPLE
P:=proc(i) local a, n; a:=2; print(1); print(2); for n from 3 by 1 to i do a:=1/24*((a+10^floor(1+evalf(log10(a), 100)))*(((n-2) mod 4)+((n-1) mod 4)+7*(n mod 4)-5*((n+1) mod 4))+(10*a+1)*(((n-2) mod 4)+7*((n-1) mod 4)-5*(n mod 4)+((n+1) mod 4))+(a-10^floor(evalf(log10(a), 100)))*(7*((n-2) mod 4)-5*((n-1) mod 4)+(n mod 4)+((n+1) mod 4))+(10*a+2)*(-5*((n-2) mod 4)+((n-1) mod 4)+(n mod 4)+7*((n+1) mod 4))); print(a); od; end: P(200); # Paolo P. Lava, Oct 02 2009
CROSSREFS
KEYWORD
easy,base,nonn
AUTHOR
EXTENSIONS
Terms a(21) onward from John W. Layman, Sep 22 2009
Edited by N. J. A. Sloane, Oct 06 2009
STATUS
approved