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!)
A354330 Distance from the sum of the first n positive triangular numbers to the nearest triangular number. 5
0, 0, 1, 0, 1, 1, 1, 6, 0, 6, 10, 10, 13, 10, 1, 14, 4, 21, 12, 4, 0, 1, 8, 22, 28, 1, 36, 1, 35, 30, 10, 4, 11, 10, 0, 20, 51, 41, 10, 71, 4, 62, 41, 6, 45, 75, 91, 88, 97, 85, 55, 10, 51, 100, 10, 99, 20, 124, 29, 56, 130, 90, 48, 20, 7, 10, 30, 68, 125, 136 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,8
COMMENTS
a(n) = 0 for n in {0, 1, 3, 8, 20, 34} = A224421.
LINKS
Wikipedia, Triangular number.
FORMULA
a(n) = A053616(A000292(n)).
a(n) = abs(A000292(n) - A354329(n)).
EXAMPLE
a(4) = 1 because the sum of the first 4 positive triangular numbers is 1 + 3 + 6 + 10 = 20, the nearest triangular number is 21 and 21 - 20 = 1.
MATHEMATICA
nterms=100; Table[ts=n(n+1)(n+2)/3; t=Floor[Sqrt[ts]]; Abs[t^2+t-ts]/2, {n, 0, nterms-1}]
PROG
(PARI)
a(n)=my(ts=n*(n+1)*(n+2)/3, t=sqrtint(ts)); abs(t^2+t-ts)/2;
vector(100, n, a(n-1)) \\ Paolo Xausa, Jul 06 2022
(Python)
from math import isqrt
def A354330(n): return abs((m:=isqrt(k:=n*(n*(n + 3) + 2)//3))*(m+1)-k)>>1 # Chai Wah Wu, Jul 15 2022
CROSSREFS
Sequence in context: A368501 A198752 A141462 * A055955 A165071 A341483
KEYWORD
nonn,easy
AUTHOR
Paolo Xausa, Jun 04 2022
STATUS
approved

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 September 14 12:31 EDT 2024. Contains 375921 sequences. (Running on oeis4.)