login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = t(n) - s(n) where s(n) = n*(n-1)/2 is the sum of the first n nonnegative integers and t(n) is the smallest sum of consecutive integers starting from n such that t(n) > s(n).
1

%I #49 Jul 20 2022 22:37:52

%S 1,1,4,3,1,6,3,10,6,1,10,4,15,8,21,13,4,19,9,26,15,3,22,9,30,16,1,24,

%T 8,33,16,43,25,6,35,15,46,25,3,36,13,48,24,61,36,10,49,22,63,35,6,49,

%U 19,64,33,1,48,15,64,30,81,46,10,63,26,81,43,4,61,21,80,39,100,58,15,78,34,99

%N a(n) = t(n) - s(n) where s(n) = n*(n-1)/2 is the sum of the first n nonnegative integers and t(n) is the smallest sum of consecutive integers starting from n such that t(n) > s(n).

%C Record high values of a(n)/n approach sqrt(2) and occur at values of n that are terms of A011900; a(A011900(k)) = A046090(k). - _Jon E. Schoenfield_, Jun 23 2022

%C It appears that the sequence 1,2,4,5,6,8,... (the largest integer in the t(n) sum) is A288998. - _Michel Marcus_, Jun 24 2022

%F From _Jon E. Schoenfield_, Jun 23 2022: (Start)

%F a(n) = t(n) - s(n) where

%F s(n) = n*(n-1)/2,

%F j = floor(sqrt(8*n^2 - 8*n + 1)),

%F m = ceiling(j/2) - n + 1, and

%F t(n) = (m*(m + 2*n - 1))/2. (End)

%e a(6) = -s(6) + t(6):

%e s(6) is the sum of the first 6 nonnegative integers = 6*5 / 2 = 15.

%e t(6) is the smallest sum k of consecutive integers starting from n = 6 such that k > s(6) = 15.

%e The first few sets of consecutive integers starting from 6 are

%e {6}, whose elements add up to 6,

%e {6, 7}, whose elements add up to 13,

%e {6, 7, 8}, whose elements add up to 21,

%e {6, 7, 8, 9}, whose elements add up to 30,

%e ...

%e the smallest sum that is > 15 is 21, so t(6) = 21, so a(6) = -15 + 21 = 6.

%o (JavaScript)

%o function a(n) {

%o var sum = 0;

%o for (var i = 0; i < n; i++)

%o sum -= i;

%o while (sum <= 0)

%o sum += i++;

%o return sum;

%o }

%o (PARI) a(n) = my(t=0, s=n*(n-1)/2, k=n); until (t > s, t += k; k ++); t-s; \\ _Michel Marcus_, Jun 24 2022

%o (Python)

%o from math import isqrt

%o def A355182(n): return ((m:=(isqrt(((k:=n*(n-1))<<3)+1)+1)>>1)*(m+1)>>1)-k # _Chai Wah Wu_, Jul 14 2022

%Y Cf. A000217, A001477, A093001.

%Y Cf. A288998.

%K nonn

%O 1,3

%A _Andrea La Rosa_, Jun 23 2022