# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/
Search: id:a295559
Showing 1-1 of 1
%I A295559 #17 Dec 27 2017 02:05:23
%S A295559 0,1,3,6,6,6,12,18,12,6,12,18,18,18,30,42,24,6,12,18,18,18,30,42,30,
%T A295559 18,30,42,42,42,66,90,48,6,12,18,18,18,30,42,30,18,30,42,42,42,66,90,
%U A295559 54,18,30,42,42,42,66,90,66,42,66,90,90,90,138,186,96,6,12
%N A295559 Same as A161645 except that triangles must always grow outwards.
%C A295559 Note that Reed's version has errors (see A295558).
%D A295559 R. Reed, The Lemming Simulation Problem, Mathematics in School, 3 (#6, Nov. 1974), front cover and pp. 5-6. [Describes the dual structure where new triangles are joined at vertices rather than edges.]
%H A295559 Lars Blomberg, Table of n, a(n) for n = 0..10000
%H A295559 R. Reed, The Lemming Simulation Problem, Mathematics in School, 3 (#6, Nov. 1974), front cover and pp. 5-6. [Scanned photocopy of pages 5, 6 only, with annotations by R. K. Guy and N. J. A. Sloane]
%H A295559 N. J. A. Sloane, Illustration of first 7 generations of A161644 and A295560 (edge-to-edge version)
%H A295559 N. J. A. Sloane, Illustration of first 11 generations of A161644 and A295560 (vertex-to-vertex version) [Include the 6 cells marked x to get A161644(11), exclude them to get A295560(11).]
%H A295559 N. J. A. Sloane, Catalog of Toothpick and Cellular Automata Sequences in the OEIS
%F A295559 From _Lars Blomberg_, Dec 20 2017: (Start)
%F A295559 Empirically (correct to 3*10^6 terms):
%F A295559 Convert n+1 to binary and view it as 1a1b or 1a1b1,
%F A295559 where a is zero or more digits, let "ones" be the number of 1's in a,
%F A295559 and b is zero or more 0's, let "zeros" be the number of 0's.
%F A295559 Let "len" be the total number of binary digits.
%F A295559 Then r=A295559(n) is determined by ones, zeros, len, and the parity of n+1, as follows:
%F A295559 if (n==0,1,2) r=0,1,3
%F A295559 else if (n+1 is odd)
%F A295559 if (len==zeros+2) r=BVal(1, zeros-1) else if (zeros==0) r=BVal(ones+1, ones+1) else r=BVal(ones+2, ones+zeros)
%F A295559 else
%F A295559 if (len==zeros+1) r=AVal(zeros-2) else r=AVal(ones+zeros-1)
%F A295559 and
%F A295559 AVal(k)=6*(2^(k+1)-1)
%F A295559 BVal(k, kk)=3*2^k + sum(j=0,kk-1, 6 * 2^j) (End)
%o A295559 (PARI) \\ Empirically discovered algorithm.
%o A295559 AVal(k)=6*(2^(k+1)-1)
%o A295559 BVal(k, kk)={ local v; v = 3 * 2^k; for (j=0,kk-1,v += 6 * 2^j);v}
%o A295559 A295559(n)={ local (len,zeros,ones,r);
%o A295559 if(n==0, return(0));
%o A295559 if(n==1, return(1));
%o A295559 if(n==2, return(3));
%o A295559 n++; len=length(binary(n));
%o A295559 zeros=ones=0; i=bittest(n,0); \\ Skip trailing 1
%o A295559 while(bittest(n,i)==0,zeros++;i++);
%o A295559 for(j=i+1,len-2,ones+=bittest(n,j));
%o A295559 if (bittest(n,0)==1,
%o A295559 if (len==zeros+2, r=BVal(1, zeros-1), if (zeros==0, r=BVal(ones+1, ones+1), r=BVal(ones+2, ones+zeros))),
%o A295559 if (len==zeros+1, r=AVal(zeros-2), r=AVal(ones+zeros-1)));
%o A295559 r;}
%o A295559 vector(200,i,A295559(i-1))
%o A295559 \\ _Lars Blomberg_, Dec 20 2017
%Y A295559 Cf. A161644, A161645, A295560.
%K A295559 nonn
%O A295559 0,3
%A A295559 _N. J. A. Sloane_, Nov 27 2017
%E A295559 Terms a(18) and beyond from _Lars Blomberg_, Dec 20 2017
# Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE