login
Minimum number n, not already present, that permits the cyclic repetition of the decimal digits 1,2,3,4,5,6,7,8,9 in the sequence.
9

%I #12 Aug 16 2015 22:00:48

%S 1,2,3,4,5,6,7,8,9,12,34,56,78,91,23,45,67,89,123,456,789,1234,567,

%T 891,234,5678,912,345,678,9123,4567,8912,3456,7891,2345,6789,12345,

%U 67891,23456,78912,34567,89123,45678,91234,56789,123456,789123,456789,1234567

%N Minimum number n, not already present, that permits the cyclic repetition of the decimal digits 1,2,3,4,5,6,7,8,9 in the sequence.

%C This sequence has a nice graph. - _M. F. Hasler_, Aug 16 2015

%H Ivan Neretin, <a href="/A165307/b165307.txt">Table of n, a(n) for n = 1..500</a>

%e Starting from 1,2,3,4,5,6,7,8,9 the next number is 12 because after 1,2,3,4,5,6,7,8,9 we must continue with a digit '1'. But 1 is already in the sequence so we need to append a 2, which yields 12. And so on.

%t a = {1}; c = 0; Do[c = 10 c + Mod[n, 9] + 1; If[! MemberQ[a, c], AppendTo[a, c]; c = 0], {n, 160}]; a (* _Ivan Neretin_, Aug 14 2015 *)

%o (PARI) a(n,show=0,u=[],d=[1,1])={my(s(d)=Strchr(vectorsmall(d[1],i,(d[2]-2+i)%9+49)));while(n--,show&&print1(s(d)",");u=setunion(u,[d]);#u>9 && u[10]==[u[1][1]+1,1] && u=u[10..-1];d=(d[1]+d[2]-1)%9+1;for(nd=u[1][1],9e9,if(!setsearch(u,[nd,d]),d=[nd,d];next(2))));eval(s(d))} \\ _M. F. Hasler_, Aug 16 2015

%Y Cf. A165300, A165301, A165302, A165303, A165304, A165305, A165306.

%Y Cf. A081549 (strictly increasing version).

%K easy,nonn,base,look

%O 1,2

%A _Paolo P. Lava_ and _Giorgio Balzarotti_, Sep 14 2009

%E Edited by _Charles R Greathouse IV_, Aug 03 2010