cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A295559 Same as A161645 except that triangles must always grow outwards.

Original entry on oeis.org

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, 18, 30, 42, 42, 42, 66, 90, 48, 6, 12, 18, 18, 18, 30, 42, 30, 18, 30, 42, 42, 42, 66, 90, 54, 18, 30, 42, 42, 42, 66, 90, 66, 42, 66, 90, 90, 90, 138, 186, 96, 6, 12
Offset: 0

Views

Author

N. J. A. Sloane, Nov 27 2017

Keywords

Comments

Note that Reed's version has errors (see A295558).

References

  • 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.]

Crossrefs

Programs

  • PARI
    \\ Empirically discovered algorithm.
    AVal(k)=6*(2^(k+1)-1)
    BVal(k, kk)={ local v; v = 3 * 2^k; for (j=0,kk-1,v += 6 * 2^j);v}
    A295559(n)={ local (len,zeros,ones,r);
    if(n==0, return(0));
    if(n==1, return(1));
    if(n==2, return(3));
    n++; len=length(binary(n));
    zeros=ones=0; i=bittest(n,0);  \\ Skip trailing 1
    while(bittest(n,i)==0,zeros++;i++);
    for(j=i+1,len-2,ones+=bittest(n,j));
    if (bittest(n,0)==1,
    if (len==zeros+2, r=BVal(1, zeros-1), if (zeros==0, r=BVal(ones+1, ones+1), r=BVal(ones+2, ones+zeros))),
    if (len==zeros+1, r=AVal(zeros-2), r=AVal(ones+zeros-1)));
    r;}
    vector(200,i,A295559(i-1))
    \\ Lars Blomberg, Dec 20 2017

Formula

From Lars Blomberg, Dec 20 2017: (Start)
Empirically (correct to 3*10^6 terms):
Convert n+1 to binary and view it as 1a1b or 1a1b1,
where a is zero or more digits, let "ones" be the number of 1's in a,
and b is zero or more 0's, let "zeros" be the number of 0's.
Let "len" be the total number of binary digits.
Then r=A295559(n) is determined by ones, zeros, len, and the parity of n+1, as follows:
if (n==0,1,2) r=0,1,3
else if (n+1 is odd)
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)
else
if (len==zeros+1) r=AVal(zeros-2) else r=AVal(ones+zeros-1)
and
AVal(k)=6*(2^(k+1)-1)
BVal(k, kk)=3*2^k + sum(j=0,kk-1, 6 * 2^j) (End)

Extensions

Terms a(18) and beyond from Lars Blomberg, Dec 20 2017