login
Number of ones in XOR-triangle with first row generated from the binary expansion of n.
6

%I #22 May 09 2020 00:51:17

%S 1,2,2,3,4,4,3,4,6,5,7,5,7,6,4,5,8,9,8,8,7,10,9,7,8,9,10,8,9,8,5,6,10,

%T 10,12,12,12,10,12,10,12,8,12,12,14,12,12,8,12,12,10,12,12,14,12,10,

%U 12,12,12,10,12,10,6,7,12,14,13,12,15,15,16,14,17,15

%N Number of ones in XOR-triangle with first row generated from the binary expansion of n.

%C An XOR-triangle is an inverted 0-1 triangle formed by choosing a top row and having each entry in the subsequent rows be the XOR of the two values above it.

%C Records occur at 1, 2, 4, 5, 9, 11, 17, 18, 22, 35, 45, 69, 71, 73, 91, 139, 142, 146, 182, ...

%H Peter Kagey, <a href="/A334593/b334593.txt">Table of n, a(n) for n = 1..8191</a>

%H MathOverflow user DSM, <a href="https://mathoverflow.net/q/359138/104733">Number triangle</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) = A000217(A070939(n)) - A334592(n).

%e For n = 53, a(53) = 12 because 53 = 110101_2 in binary, and the corresponding XOR-triangle has 12 ones:

%e 1 1 0 1 0 1

%e 0 1 1 1 1

%e 1 0 0 0

%e 1 0 0

%e 1 0

%e 1

%t Array[Total@ Flatten@ NestWhileList[Map[BitXor @@ # &, Partition[#, 2, 1]] &, IntegerDigits[#, 2], Length@ # > 1 &] &, 74] (* _Michael De Vlieger_, May 08 2020 *)

%o (PARI) a(n) = {my(b=binary(n), nb=hammingweight(n)); for (n=1, #b-1, b = vector(#b-1, k, bitxor(b[k], b[k+1])); nb += vecsum(b);); nb;} \\ _Michel Marcus_, May 08 2020

%Y Cf. A000217, A070939.

%Y Cf. A334556, A334591, A334592, A334594, A334595, A334596.

%K nonn,base

%O 1,2

%A _Peter Kagey_, May 07 2020