OFFSET
1,5
COMMENTS
The array gives the values of bivariate function F(p,q) which is well-defined only when q is odd, thus while here its argument p obtains all integer values from 1 onward, argument q gets only odd numbers 1, 3, 5, 7, 9, ... as its values.
Any row n occurs also as row (4^k * n), for all k >= 0.
LINKS
FORMULA
A(row,col) = F(row,(2*col)-1), where function F is defined as: If p <= 1, F(p,q) = 0, otherwise if p is an odd number > 1, F(p,q) = F(q mod p, p) XOR (p AND q), otherwise [when p is an even number] F(p,q) = F(p/2,q) XOR A003188(q).
EXAMPLE
The top left [1 .. 16] x [1 .. 25] section of the array:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16
1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1, 2, 5, 2, 1, 1, 6, 5, 6, 1, 5, 6, 1, 6, 5, 5
0, 1, 4, 7, 12, 15, 10, 11, 26, 25, 30, 29, 20, 21, 16, 19
1, 0, 7, 7, 5, 3, 2, 7, 2, 1, 5, 3, 1, 4, 5, 4
1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16
1, 0, 0, 4, 9, 4, 9, 5, 12, 1, 0, 0, 12, 9, 4, 9
0, 0, 2, 6, 12, 15, 13, 13, 31, 27, 26, 26, 20, 16, 22, 21
1, 2, 0, 0, 13, 11, 7, 11, 14, 13, 14, 3, 8, 10, 10, 15
1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3
1, 0, 3, 7, 0, 14, 13, 6, 1, 11, 14, 8, 8, 9, 12, 11
0, 2, 0, 3, 8, 13, 9, 15, 27, 27, 26, 31, 20, 18, 22, 20
1, 0, 0, 0, 12, 0, 11, 15, 9, 3, 14, 15, 4, 8, 2, 15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1, 2, 7, 3, 13, 15, 0, 8, 17, 8, 17, 11, 8, 14, 18, 10
0, 2, 7, 0, 4, 10, 2, 13, 21, 27, 31, 28, 25, 31, 23, 25
1, 0, 0, 2, 0, 14, 10, 0, 25, 19, 11, 19, 8, 9, 10, 16
1, 2, 5, 2, 1, 1, 6, 5, 6, 1, 5, 6, 1, 6, 5, 5
1, 0, 0, 0, 1, 15, 11, 11, 0, 26, 21, 10, 17, 15, 10, 15
0, 0, 7, 4, 0, 5, 12, 3, 23, 23, 17, 31, 29, 28, 25, 31
1, 2, 3, 4, 1, 0, 13, 8, 26, 0, 31, 23, 13, 19, 8, 11
0, 1, 4, 7, 12, 15, 10, 11, 26, 25, 30, 29, 20, 21, 16, 19
1, 0, 0, 0, 5, 1, 1, 13, 25, 25, 0, 28, 25, 12, 25, 13
MATHEMATICA
F[p_, q_] := F[p, q] = Which[p <= 1, 0, p > 1 && OddQ[p], F[Mod[q, p], p] ~BitXor~ BitAnd[p, q], True, F[p/2, q] ~BitXor~ BitXor[q, Floor[q/2]]];
A[n_, k_] := F[n, 2 k - 1];
Table[A[n - k, k], {n, 1, 14}, {k, 1, n}] // Flatten (* Jean-François Alcover, Sep 11 2017 *)
PROG
(Scheme)
;; A269158auxbi can be implemented either as a tail-recursive loop:
(define (A269158auxbi p q) (if (not (odd? q)) (error "A269158bi: the second argument should be odd: " p q) (let loop ((p p) (q q) (s 0)) (cond ((<= p 1) s) ((odd? p) (loop (modulo q p) p (A003987bi s (A004198bi p q)))) (else (loop (/ p 2) q (A003987bi s (A003987bi q (/ (- q 1) 2)))))))))
;; Or a recurrence (reflecting the given recursive formula):
(define (A269158auxbi p q) (cond ((<= p 1) 0) ((even? p) (A003987bi (A269158auxbi (/ p 2) q) (A003188 q))) (else (A003987bi (A269158auxbi (modulo q p) p) (A004198bi p q)))))
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, Feb 20 2016
STATUS
approved