login
The smallest possible nonnegative difference between the sum of the first n positive integers (A000217) and the sum of any number of the directly following and consecutive integers.
1

%I #24 Aug 24 2019 13:36:21

%S 1,0,2,5,2,6,1,6,12,5,12,3,11,0,9,19,6,17,2,14,27,10,24,5,20,36,15,32,

%T 9,27,2,21,41,14,35,6,28,51,20,44,11,36,1,27,54,17,45,6,35,65,24,55,

%U 12,44,77,32,66,19,54,5,41,78,27,65,12,51,91,36,77,20,62

%N The smallest possible nonnegative difference between the sum of the first n positive integers (A000217) and the sum of any number of the directly following and consecutive integers.

%C a(n) = 0 if a positive integer m exists, such that m * (m + 1) = 2 * n * (n + 1). Let k = m - n, then n = (2 * k - 1 + sqrt(8 * k^2 + 1)) / 2. All k for which 8 * k^2 + 1 is a perfect square (A001109) yield a value for n for which a(n) = 0.

%C a(A053141(n)) = 0 for all n.

%e a(2) = 1 + 2 - 3 = 0;

%e a(3) = 1 + 2 + 3 - 4 = 2;

%e a(7) = 1 + 2 + 3 + 4 + 5 + 6 + 7 - (8 + 9 + 10) = 1.

%e a(A053141(2)) = a(14) = 0, because A000217(20) = 2 * A000217(14).

%o (PARI) a(n) = {my(t=n*(n+1)/2, k = n+1); while(t >= k, t -= k; k++); t;} \\ _Michel Marcus_, Aug 16 2019

%Y Cf. A000217, A001109, A001652, A053141, A309655.

%K nonn

%O 1,3

%A _Bob Andriesse_, Aug 13 2019