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.

A246595 Run Length Transform of squares.

Original entry on oeis.org

1, 1, 1, 4, 1, 1, 4, 9, 1, 1, 1, 4, 4, 4, 9, 16, 1, 1, 1, 4, 1, 1, 4, 9, 4, 4, 4, 16, 9, 9, 16, 25, 1, 1, 1, 4, 1, 1, 4, 9, 1, 1, 1, 4, 4, 4, 9, 16, 4, 4, 4, 16, 4, 4, 16, 36, 9, 9, 9, 36, 16, 16, 25, 36, 1, 1, 1, 4, 1, 1, 4, 9, 1, 1, 1, 4, 4, 4, 9, 16, 1, 1, 1, 4, 1, 1
Offset: 0

Views

Author

N. J. A. Sloane, Sep 06 2014

Keywords

Comments

The Run Length Transform of a sequence {S(n), n>=0} is defined to be the sequence {T(n), n>=0} given by T(n) = Product_i S(i), where i runs through the lengths of runs of 1's in the binary expansion of n. E.g., 19 is 10011 in binary, which has two runs of 1's, of lengths 1 and 2. So T(19) = S(1)*S(2). T(0)=1 (the empty product).

Examples

			From _Omar E. Pol_, Feb 10 2015: (Start)
Written as an irregular triangle in which row lengths is A011782:
1;
1;
1,4;
1,1,4,9;
1,1,1,4,4,4,9,16;
1,1,1,4,1,1,4,9,4,4,4,16,9,9,16,25;
1,1,1,4,1,1,4,9,1,1,1,4,4,4,9,16,4,4,4,16,4,4,16,36,9,9,9,36,16,16,25,36;
...
Right border gives A253909: 1 together with the positive squares.
(End)
From _Omar E. Pol_, Mar 19 2015: (Start)
Also, the sequence can be written as an irregular tetrahedron T(s,r,k) as shown below:
1;
..
1;
..
1;
4;
.......
1,   1;
4;
9;
...............
1,   1,  1,  4;
4,   4;
9;
16;
.............................
1,   1,  1,  4, 1, 1,  4,  9;
4,   4,  4, 16;
9,   9;
16;
25;
......................................................
1,   1,  1,  4, 1, 1,  4,  9, 1, 1, 1, 4, 4, 4, 9, 16;
4,   4,  4, 16, 4, 4, 16, 36;
9,   9,  9, 36;
16, 16;
25;
36;
...
Apart from the initial 1, we have that T(s,r,k) = T(s+1,r,k).
(End)
		

Crossrefs

Cf. A003714 (gives the positions of ones).
Run Length Transforms of other sequences: A071053, A227349, A246588, A246596, A246660, A246661, A246674.

Programs

  • Maple
    ans:=[];
    for n from 0 to 100 do lis:=[]; t1:=convert(n, base, 2); L1:=nops(t1); out1:=1; c:=0;
    for i from 1 to L1 do
       if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;
       elif out1 = 0 and t1[i] = 1 then c:=c+1;
       elif out1 = 1 and t1[i] = 0 then c:=c;
       elif out1 = 0 and t1[i] = 0 then lis:=[c, op(lis)]; out1:=1; c:=0;
       fi;
       if i = L1 and c>0 then lis:=[c, op(lis)]; fi;
                       od:
    a:=mul(i^2, i in lis);
    ans:=[op(ans), a];
    od:
    ans;
  • Mathematica
    Table[Times @@ (Length[#]^2&) /@ Select[Split[IntegerDigits[n, 2]], #[[1]] == 1&], {n, 0, 85}] (* Jean-François Alcover, Jul 11 2017 *)
  • Python
    from operator import mul
    from functools import reduce
    from re import split
    def A246595(n):
        return reduce(mul,(len(d)**2 for d in split('0+',bin(n)[2:]) if d != '')) if n > 0 else 1 # Chai Wah Wu, Sep 07 2014
    
  • Sage
    # uses[RLT from A246660]
    A246595_list = lambda len: RLT(lambda n: n^2, len)
    A246595_list(86) # Peter Luschny, Sep 07 2014
    
  • Scheme
    ; using MIT/GNU Scheme
    (define (A246595 n) (fold-left (lambda (a r) (* a r r)) 1 (bisect (reverse (binexp->runcount1list n)) (- 1 (modulo n 2)))))
    ;; Other functions are as in A227349 - Antti Karttunen, Sep 08 2014

Formula

a(n) = A227349(n)^2. - Omar E. Pol, Feb 10 2015