OFFSET
0,4
COMMENTS
Leading 0's are taken into account.
FORMULA
EXAMPLE
Array A(n, k) begins:
n\k| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
---+----------------------------------------------------------
0| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1| 1 1 1 3 1 5 5 7 1 9 9 11 9 13 13 15
2| 2 1 2 3 2 5 6 7 2 9 10 11 10 13 14 15
3| 3 3 3 3 3 3 3 7 3 3 3 11 3 11 11 15
4| 4 1 2 3 4 5 6 7 4 9 10 11 12 13 14 15
5| 5 5 5 3 5 5 5 7 5 5 5 11 5 13 13 15
6| 6 5 6 3 6 5 6 7 6 5 6 11 6 13 14 15
7| 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 15
8| 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
9| 9 9 9 3 9 5 5 7 9 9 9 11 9 13 13 15
10| 10 9 10 3 10 5 6 7 10 9 10 11 10 13 14 15
.
For n = 876 and k = 425:
- the corresponding binary expansions and pairings of 0's are as follows (stars indicate greatest positions of 0's):
* * * * *
876 ... 0 0 0 1 1 0 1 1 0 1 1 0 0
\ \ \ \ | / /
425 ... 0 0 0 0 1 1 0 1 0 1 0 0 1
* * *
-----------------------------
873 ... 0 0 0 1 1 0 1 1 0 1 0 0 1
- so A(876, 425) = 873.
PROG
(PARI) A(n, k) = { my (v=0, zn=0, zk=0, w=1, b=1); while (n || k, if (n%2==0, zn++); if (k%2==0, zk++); if (min(zn, zk)==w, w++, v+=b); n\=2; k\=2; b*=2); v }
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Jun 25 2022
STATUS
approved