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.
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
Examples
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.
Programs
-
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
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
Extensions
Terms a(21) onward from John W. Layman, Sep 22 2009
Edited by N. J. A. Sloane, Oct 06 2009
Comments