OFFSET
1,4
COMMENTS
Since the sum of two distinct integers from 1 to n can be as much as 2n-1, this triangular table cannot show all the possible cases. For larger triangles showing all solutions, see A220691 and A220693. - Antti Karttunen, Feb 18 2013 [based on Robert Israel's mail, May 07 2012]
LINKS
Reinhard Zumkeller, Rows n = 1..150 of triangle, flattened
Stackexchange, Question 142323
FORMULA
From Robert Israel, May 08 2012: (Start)
Let n+1 = b mod k with 0 <= b < k, q = (n+1-b)/k. Let k = c mod 2, c = 0 or 1.
If b = 0 or 1 then a(n,k) = q^2*k/2 + q*b - 2*q - b + 1 + c*q/2.
If b >= (k+3)/2 then a(n,k) = q^2*k/2 + q*b - 2*q + b - 1 - k/2 + c*(q+1)/2.
Otherwise a(n,k) = q^2*k/2 + q*b - 2*q + c*q/2. (End)
EXAMPLE
The second term on the sixth row is 6 because we have 6 solutions: {1+3, 1+5, 2+4, 2+6, 3+5, 4+6} and the third term on the same row is 5 because we have solutions {1+2,1+5,2+4,3+6,4+5}.
Triangle begins:
0;
1, 0;
3, 1, 1;
6, 2, 2, 1;
10, 4, 4, 2, 2;
15, 6, 5, 3, 3, 2;
21, 9, 7, 5, 4, 3, 3;
28, 12, 10, 6, 6, 4, 4, 3;
36, 16, 12, 8, 8, 5, 5, 4, 4;
45, 20, 15, 10, 9, 7, 6, 5, 5, 4;
MAPLE
[seq(DivSumChoose2Triangle(j), j=1..120)]; DivSumChoose2Triangle := (n) -> nops(DivSumChoose2(trinv(n-1), (n-((trinv(n-1)*(trinv(n-1)-1))/2))));
DivSumChoose2 := proc(n, k) local a, i, j; a := []; for i from 1 to (n-1) do for j from (i+1) to n do if(0 = ((i+j) mod k)) then a := [op(a), [i, j]]; fi; od; od; RETURN(a); end;
MATHEMATICA
a[n_, 1] := n*(n-1)/2; a[n_, k_] := Module[{r}, r = Reduce[1 <= i < j <= n && Mod[i + j, k] == 0, {i, j}, Integers]; Which[Head[r] === Or, Length[r], Head[r] === And, 1, r === False, 0, True, Print[r, " not parsed"]]]; Table[a[n, k], {n, 1, 13}, {k, 1, n}] // Flatten (* Jean-François Alcover, Mar 04 2014 *)
PROG
(Haskell)
a061857 n k = length [()| i <- [2..n], j <- [1..i-1], mod (i + j) k == 0]
a061857_row n = map (a061857 n) [1..n]
a061857_tabl = map a061857_row [1..]
-- Reinhard Zumkeller, May 08 2012
(Scheme): (define (A061857 n) (A220691bi (A002024 n) (A002260 n))) - Antti Karttunen, Feb 18 2013. Needs A220691bi from A220691.
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, May 11 2001
EXTENSIONS
Offset corrected by Reinhard Zumkeller, May 08 2012
STATUS
approved