OFFSET
0,4
COMMENTS
The binary expansion of A(n, k) encodes the position of n/k (> 0) in the Calkin-Wilf tree.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10152
Wikipedia, Calkin-Wilf tree
FORMULA
EXAMPLE
Square array A(n, k) begins:
n\k| 1 2 3 4 5 6 7 8 9 10 11 12
---+-----------------------------------------------------------------
0| 0 0 0 0 0 0 0 0 0 0 0 0
1| 1 2 4 8 16 32 64 128 256 512 1024 2048
2| 3 1 6 2 12 4 24 8 48 16 96 32
3| 7 5 1 14 10 2 28 20 4 56 40 8
4| 15 3 9 1 30 6 18 2 60 12 36 4
5| 31 11 13 17 1 62 22 26 34 2 124 44
6| 63 7 3 5 33 1 126 14 6 10 66 2
7| 127 23 19 29 25 65 1 254 46 38 58 50
8| 255 15 27 3 21 9 129 1 510 30 54 6
9| 511 47 7 35 61 5 49 257 1 1022 94 14
10| 1023 31 39 11 3 13 57 17 513 1 2046 62
11| 2047 95 55 59 67 125 37 41 97 1025 1 4094
12| 4095 63 15 7 51 3 45 5 9 33 2049 1
PROG
(PARI) A(x, y) = { if (x==0, 0, my (v=0, t=1, a=0, b=1, c=1, d=0); while (1, my (m=a+c, n=b+d); if (x*n==y*m, return (t+v), x*n<y*m, [c, d]=[m, n], [v, a, b]=[v+t, m, n]); t*=2)) }
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Rémy Sigrist, Jun 18 2022
STATUS
approved