cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A355182 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).

Original entry on oeis.org

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, 8, 33, 16, 43, 25, 6, 35, 15, 46, 25, 3, 36, 13, 48, 24, 61, 36, 10, 49, 22, 63, 35, 6, 49, 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
Offset: 1

Views

Author

Andrea La Rosa, Jun 23 2022

Keywords

Comments

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
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

Examples

			a(6) = -s(6) + t(6):
s(6) is the sum of the first 6 nonnegative integers = 6*5 / 2 = 15.
t(6) is the smallest sum k of consecutive integers starting from n = 6 such that k > s(6) = 15.
The first few sets of consecutive integers starting from 6 are
  {6}, whose elements add up to 6,
  {6, 7}, whose elements add up to 13,
  {6, 7, 8}, whose elements add up to 21,
  {6, 7, 8, 9}, whose elements add up to 30,
  ...
the smallest sum that is > 15 is 21, so t(6) = 21, so a(6) = -15 + 21 = 6.
		

Crossrefs

Programs

  • JavaScript
    function a(n) {
        var sum = 0;
        for (var i = 0; i < n; i++)
            sum -= i;
        while (sum <= 0)
            sum += i++;
        return sum;
    }
    
  • 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
    
  • Python
    from math import isqrt
    def A355182(n): return ((m:=(isqrt(((k:=n*(n-1))<<3)+1)+1)>>1)*(m+1)>>1)-k # Chai Wah Wu, Jul 14 2022

Formula

From Jon E. Schoenfield, Jun 23 2022: (Start)
a(n) = t(n) - s(n) where
s(n) = n*(n-1)/2,
j = floor(sqrt(8*n^2 - 8*n + 1)),
m = ceiling(j/2) - n + 1, and
t(n) = (m*(m + 2*n - 1))/2. (End)