OFFSET
0,3
COMMENTS
For any nonnegative number n, the EQ-triangle for n is built by taking as first row the binary expansion of n (without leading zeros), having each entry in the subsequent rows be the EQ of the two values above it (a "1" indicates that these two values are equal, a "0" indicates that these values are different).
This sequence is a self-inverse permutation of the nonnegative numbers.
LINKS
FORMULA
EXAMPLE
For n = 42:
- the binary representation of 42 is "101010",
- the corresponding EQ-triangle is:
1 0 1 0 1 0
0 0 0 0 0
1 1 1 1
1 1 1
1 1
1
- the bits on the left diagonal are: 1, 0, 1, 1, 1, 1,
- so a(42) = 2^5 + 2^3 + 2^2 + 2^1 + 2^0 = 47.
PROG
(PARI) a(n) = {
my (b=binary(n), v=0);
forstep (x=#b-1, 0, -1,
if (b[1], v+=2^x);
b=vector(#b-1, k, b[k]==b[k+1])
);
return (v)
}
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, May 24 2020
STATUS
approved