A165307 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.
1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 34, 56, 78, 91, 23, 45, 67, 89, 123, 456, 789, 1234, 567, 891, 234, 5678, 912, 345, 678, 9123, 4567, 8912, 3456, 7891, 2345, 6789, 12345, 67891, 23456, 78912, 34567, 89123, 45678, 91234, 56789, 123456, 789123, 456789, 1234567
Offset: 1
Examples
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.
Links
- Ivan Neretin, Table of n, a(n) for n = 1..500
Crossrefs
Programs
-
Mathematica
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 *)
-
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
Extensions
Edited by Charles R Greathouse IV, Aug 03 2010
Comments