login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A220691 Table A(i,j) read by antidiagonals in order A(1,1), A(1,2), A(2,1), A(1,3), A(2,2), A(3,1), ..., where A(i,j) is the number of ways in which we can add 2 distinct integers from the range 1..i in such a way that the sum is divisible by j. 4

%I #23 Jun 12 2021 23:33:02

%S 0,0,1,0,0,3,0,1,1,6,0,0,1,2,10,0,0,1,2,4,15,0,0,1,1,4,6,21,0,0,0,2,2,

%T 5,9,28,0,0,0,1,2,3,7,12,36,0,0,0,1,2,3,5,10,16,45,0,0,0,0,2,2,4,6,12,

%U 20,55,0,0,0,0,1,3,3,6,8,15,25,66,0,0,0,0

%N Table A(i,j) read by antidiagonals in order A(1,1), A(1,2), A(2,1), A(1,3), A(2,2), A(3,1), ..., where A(i,j) is the number of ways in which we can add 2 distinct integers from the range 1..i in such a way that the sum is divisible by j.

%H A. Karttunen, <a href="/A220691/b220691.txt">The first 150 antidiagonals of the square array, flattened</a>

%H Stackexchange, <a href="http://math.stackexchange.com/questions/142323/sequence-generation/142364">Question 142323</a>

%H <a href="/index/Su#subsetsums">Index entries for sequences related to subset sums modulo m</a>

%F See _Robert Israel_'s formula at A061857.

%e The upper left corner of this square array starts as:

%e 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...

%e 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, ...

%e 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, ...

%e 6, 2, 2, 1, 2, 1, 1, 0, 0, 0, 0, ...

%e 10, 4, 4, 2, 2, 2, 2, 1, 1, 0, 0, ...

%e 15, 6, 5, 3, 3, 2, 3, 2, 2, 1, 1, ...

%e Row 1 is all zeros, because it's impossible to choose two distinct integers from range [1]. A(2,1) = 1, as there is only one possibility to choose a pair of distinct numbers from the range [1,2] such that it is divisible by 1, namely 1+2. Also A(2,3) = 1, as 1+2 is divisible by 3.

%e A(4,1) = 2, as from [1,2,3,4] one can choose two pairs of distinct numbers whose sum is even: {1+3} and {2+4}.

%t 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+1, k], {n, 1, 13} , {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Mar 04 2014 *)

%o (Scheme function, written after _Robert Israel_'s formula given at A061857):

%o (define (A220691 n) (A220691bi (A002260 n) (A004736 n)))

%o (define (A220691bi n k) (let* ((b (modulo (+ 1 n) k)) (q (/ (- (+ 1 n) b) k)) (c (modulo k 2))) (cond ((< b 2) (+ (* q q k (/ 1 2)) (* q b) (* -2 q) (* -1 b) 1 (* c q (/ 1 2)))) ((>= b (/ (+ k 3) 2)) (+ (* q q k (/ 1 2)) (* q b) (* -2 q) b -1 (* (/ k -2)) (* c (+ 1 q) (/ 1 2)))) (else (+ (* q q k (/ 1 2)) (* q b) (* -2 q) (* c q (/ 1 2)))))))

%Y Transpose: A220692. The lower triangular region of this square array is given by A061857, which leaves out about half of the nonzero terms. A220693 is another variant giving 2n-1 terms from the beginning of each row, thus containing all the nonzero terms of this array.

%Y The left column of the table: A000217. The following cases should be checked: the second column: A002620, the third column: A058212 (after the first two terms), the fourth column: A001971.

%K nonn,tabl

%O 1,6

%A _Antti Karttunen_, Feb 18 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 29 04:08 EDT 2024. Contains 374727 sequences. (Running on oeis4.)