Search: id:A006345 Results 1-1 of 1 results found. %I A006345 M0074 %S A006345 1,2,1,1,2,2,1,2,1,1,2,1,2,2,1,1,2,1,1,1,2,2,1,2,1,1,2,2,1,1,1,2,1,1,2, %T A006345 2,1,2,1,1,2,1,2,2,1,1,2,1,1,1,2,2,1,2,1,1,2,2,1,2,2,2,1,1,2,1,2,2,1,1, %U A006345 2,2,2,1,2,2,1,1,2,1,2,2,1,2,1,1,2,2,1,2,2,2,1,1,2,1,2,2,1,1,2,2,2,1,2 %N A006345 Linus sequence: a(n) "breaks the pattern" by avoiding the longest doubled suffix. %C A006345 To compute a(n), consider either a 1 or a 2. For each, find the longest repeated suffix, that is, for each of a(n)=1,2, find the longest sequence s with the property that the sequence a(1),...,a(n) ends with ss. Use the digit that results in the shorter such suffix. a(1) = 1. The empty sequence of length 0 is the shortest possible suffix and is trivially doubled. Note that this doesn't result in exactly Linus's choices (K. Ramsey, kramsey(AT)aol.com). %D A006345 N. S. Hellerstein, personal communication. %D A006345 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A006345 T. D. Noe, Table of n, a(n) for n=1..1000 %H A006345 N. J. A. Sloane, Illustration of initial terms %H A006345 Eric Weisstein's World of Mathematics, Link to a section of The World of Mathematics. %e A006345 After 1,2,1,1,2,2,1,2, if we put a 1, the suffix {2,1} repeats, but if we put a 2 the longer suffix {1,2,2} repeats, so the next term is 1. %o A006345 (Perl) -le 'print$_.=3**/(.*)(.)\1$/-$2for($_)x99' (Ton Hospel/Phil Carmody) [An example of Perl golfing: use as few (key)strokes as possible] %o A006345 (PARI) {a(n)=local(A,t); if(n<2, n>0, A=[1]; for(i=2, n, forstep(j=i\2-1, 0, -1, for(k=1, j, if(A[i-j-k-1]!=A[i-k], next(2))); t=j; break); A=concat(A,[3-A[i-t-1]])); A[n])} /* Michael Somos May 04 2006 */ %Y A006345 Cf. A006346. %Y A006345 Sequence in context: A051287 A049705 A060236 this_sequence A122497 A154402 A023396 %Y A006345 Adjacent sequences: A006342 A006343 A006344 this_sequence A006346 A006347 A006348 %K A006345 nonn,easy,nice %O A006345 1,2 %A A006345 N. J. A. Sloane (njas(AT)research.att.com). %E A006345 More terms from Naohiro Nomoto (6284968128(AT)geocities.co.jp), May 21 2001 %E A006345 Additional comments from Mitch Harris, Dec 31, 2003 Search completed in 0.001 seconds