OFFSET
1,2
LINKS
Eric Weisstein's World of Mathematics, Pairing Function
FORMULA
A(n,k) = T(remainder(n,k), quotient(n,k)), where T(n,k) is sequence A001477 considered as a two-dimensional table, that is, as a pairing function from [0, 1, 2, 3, ...] x [0, 1, 2, 3, ...] to [0, 1, 2, 3, ...]. This sequence lists only values for indices n >= 1, k >= 1.
EXAMPLE
The top left 15 X 15 corner of the array:
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
3, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
6, 4, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9
10, 3, 4, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
15, 7, 8, 4, 1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
21, 6, 3, 8, 4, 1, 27, 27, 27, 27, 27, 27, 27, 27, 27
28, 11, 7, 13, 8, 4, 1, 35, 35, 35, 35, 35, 35, 35, 35
36, 10, 12, 3, 13, 8, 4, 1, 44, 44, 44, 44, 44, 44, 44
45, 16, 6, 7, 19, 13, 8, 4, 1, 54, 54, 54, 54, 54, 54
55, 15, 11, 12, 3, 19, 13, 8, 4, 1, 65, 65, 65, 65, 65
66, 22, 17, 18, 7, 26, 19, 13, 8, 4, 1, 77, 77, 77, 77
78, 21, 10, 6, 12, 3, 26, 19, 13, 8, 4, 1, 90, 90, 90
91, 29, 16, 11, 18, 7, 34, 26, 19, 13, 8, 4, 1, 104, 104
105, 28, 23, 17, 25, 12, 3, 34, 26, 19, 13, 8, 4, 1, 119
120, 37, 15, 24, 6, 18, 7, 43, 34, 26, 19, 13, 8, 4, 1
MATHEMATICA
Map[((#1 + #2)^2 + 3 #1 + #2)/2 & @@ # & /@ Reverse@ # &, Table[Function[m, Reverse@ QuotientRemainder[m, k]][n - k + 1], {n, 14}, {k, n}]] // Flatten (* Michael De Vlieger, May 20 2017 *)
PROG
(Scheme)
(define (A286156bi row col) (if (zero? col) -1 (let ((a (remainder row col)) (b (quotient row col))) (/ (+ (expt (+ a b) 2) (* 3 a) b) 2))))
(Python)
def T(a, b): return ((a + b)**2 + 3*a + b)//2
def A(n, k): return T(n%k, n//k)
for n in range(1, 21): print([A(k, n - k + 1) for k in range(1, n + 1)]) # Indranil Ghosh, May 20 2017
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, May 04 2017
STATUS
approved