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.
%I A354330 #39 Jul 15 2022 13:50:10 %S A354330 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, %T A354330 30,10,4,11,10,0,20,51,41,10,71,4,62,41,6,45,75,91,88,97,85,55,10,51, %U A354330 100,10,99,20,124,29,56,130,90,48,20,7,10,30,68,125,136 %N A354330 Distance from the sum of the first n positive triangular numbers to the nearest triangular number. %C A354330 a(n) = 0 for n in {0, 1, 3, 8, 20, 34} = A224421. %H A354330 Paolo Xausa, <a href="/A354330/b354330.txt">Table of n, a(n) for n = 0..9999</a> %H A354330 Wikipedia, <a href="https://en.wikipedia.org/wiki/Triangular_number">Triangular number</a>. %F A354330 a(n) = A053616(A000292(n)). %F A354330 a(n) = abs(A000292(n) - A354329(n)). %e A354330 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. %t A354330 nterms=100;Table[ts=n(n+1)(n+2)/3;t=Floor[Sqrt[ts]];Abs[t^2+t-ts]/2,{n,0,nterms-1}] %o A354330 (PARI) %o A354330 a(n)=my(ts=n*(n+1)*(n+2)/3,t=sqrtint(ts));abs(t^2+t-ts)/2; %o A354330 vector(100,n,a(n-1)) \\ _Paolo Xausa_, Jul 06 2022 %o A354330 (Python) %o A354330 from math import isqrt %o A354330 def A354330(n): return abs((m:=isqrt(k:=n*(n*(n + 3) + 2)//3))*(m+1)-k)>>1 # _Chai Wah Wu_, Jul 15 2022 %Y A354330 Cf. A000217, A000292, A053616, A224421, A238455, A351830, A354329. %K A354330 nonn,easy %O A354330 0,8 %A A354330 _Paolo Xausa_, Jun 04 2022