login
Run Length Transform of squares.
11

%I #55 Mar 15 2020 06:00:07

%S 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,

%T 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,

%U 25,36,1,1,1,4,1,1,4,9,1,1,1,4,4,4,9,16,1,1,1,4,1,1

%N Run Length Transform of squares.

%C 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).

%H Chai Wah Wu, <a href="/A246595/b246595.txt">Table of n, a(n) for n = 0..8192</a>

%H N. J. A. Sloane, <a href="http://arxiv.org/abs/1503.01168">On the Number of ON Cells in Cellular Automata</a>, arXiv:1503.01168 [math.CO], 2015.

%F a(n) = A227349(n)^2. - _Omar E. Pol_, Feb 10 2015

%e From _Omar E. Pol_, Feb 10 2015: (Start)

%e Written as an irregular triangle in which row lengths is A011782:

%e 1;

%e 1;

%e 1,4;

%e 1,1,4,9;

%e 1,1,1,4,4,4,9,16;

%e 1,1,1,4,1,1,4,9,4,4,4,16,9,9,16,25;

%e 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;

%e ...

%e Right border gives A253909: 1 together with the positive squares.

%e (End)

%e From _Omar E. Pol_, Mar 19 2015: (Start)

%e Also, the sequence can be written as an irregular tetrahedron T(s,r,k) as shown below:

%e 1;

%e ..

%e 1;

%e ..

%e 1;

%e 4;

%e .......

%e 1, 1;

%e 4;

%e 9;

%e ...............

%e 1, 1, 1, 4;

%e 4, 4;

%e 9;

%e 16;

%e .............................

%e 1, 1, 1, 4, 1, 1, 4, 9;

%e 4, 4, 4, 16;

%e 9, 9;

%e 16;

%e 25;

%e ......................................................

%e 1, 1, 1, 4, 1, 1, 4, 9, 1, 1, 1, 4, 4, 4, 9, 16;

%e 4, 4, 4, 16, 4, 4, 16, 36;

%e 9, 9, 9, 36;

%e 16, 16;

%e 25;

%e 36;

%e ...

%e Apart from the initial 1, we have that T(s,r,k) = T(s+1,r,k).

%e (End)

%p ans:=[];

%p for n from 0 to 100 do lis:=[]; t1:=convert(n, base, 2); L1:=nops(t1); out1:=1; c:=0;

%p for i from 1 to L1 do

%p if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;

%p elif out1 = 0 and t1[i] = 1 then c:=c+1;

%p elif out1 = 1 and t1[i] = 0 then c:=c;

%p elif out1 = 0 and t1[i] = 0 then lis:=[c, op(lis)]; out1:=1; c:=0;

%p fi;

%p if i = L1 and c>0 then lis:=[c, op(lis)]; fi;

%p od:

%p a:=mul(i^2, i in lis);

%p ans:=[op(ans), a];

%p od:

%p ans;

%t Table[Times @@ (Length[#]^2&) /@ Select[Split[IntegerDigits[n, 2]], #[[1]] == 1&], {n, 0, 85}] (* _Jean-François Alcover_, Jul 11 2017 *)

%o (Python)

%o from operator import mul

%o from functools import reduce

%o from re import split

%o def A246595(n):

%o 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

%o (Sage) # uses[RLT from A246660]

%o A246595_list = lambda len: RLT(lambda n: n^2, len)

%o A246595_list(86) # _Peter Luschny_, Sep 07 2014

%o (Scheme) ; using MIT/GNU Scheme

%o (define (A246595 n) (fold-left (lambda (a r) (* a r r)) 1 (bisect (reverse (binexp->runcount1list n)) (- 1 (modulo n 2)))))

%o ;; Other functions are as in A227349 - _Antti Karttunen_, Sep 08 2014

%Y Cf. A000290, A253082.

%Y Cf. A003714 (gives the positions of ones).

%Y Run Length Transforms of other sequences: A071053, A227349, A246588, A246596, A246660, A246661, A246674.

%K nonn

%O 0,4

%A _N. J. A. Sloane_, Sep 06 2014