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 A140757 #18 Jun 10 2025 10:42:40 %S A140757 1,0,2,3,1,4,3,5,2,6,7,5,8,4,9,8,10,7,11,6,12,13,11,14,10,15,9,16,15, %T A140757 17,14,18,13,19,12,20,21,19,22,18,23,17,24,16,25,24,26,23,27,22,28,21, %U A140757 29,20,30,31,29,32,28,33,27,34,26,35,25,36,35,37,34,38,33,39,32,40,31,41 %N A140757 Cumulative sums of A140756. %C A140757 Each positive integer occurs exactly twice in this sequence, with 0 occurring only once. In particular, if A002620(n) < m < A002620(n+1), then m occurs in rows n-1 and n; and A002620(n) occurs in rows in rows n-1 (as T(n-1,n-1)) and n+1 (as T(n+1,n)). %H A140757 G. C. Greubel, <a href="/A140757/b140757.txt">Table of n, a(n) for n = 1..5000</a> %F A140757 T(n,k) = floor((n+(-1)^{n-k})^2/4) - (-1)^{n-k}*floor((n-k)/2), as a triangle, with n >= 1, 1 <= k <= n. %e A140757 As a triangle: %e A140757 1; %e A140757 0, 2; %e A140757 3, 1, 4; %e A140757 3, 5, 2, 6; %e A140757 7, 5, 8, 4, 9; %e A140757 8, 10, 7, 11, 6, 12; %e A140757 ... %t A140757 A140756[n_]:= With[{t=Floor[(-1+Sqrt[8*n-7])/2]}, (-1)^(Binomial[t+2, 2] -n)*(n -Binomial[t+1,2])]; %t A140757 A140757[n_]:= Sum[A140756[j], {j,n}]; %t A140757 Table[A140757[n], {n,100}] (* _G. C. Greubel_, Oct 21 2023 *) %o A140757 (PARI) T(n,k)=if((n-k)%2==0, ((n+1)^2\4)-((n-k)\2), ((n-1)^2\4)+((n-k)\2) ) \\ _Paul D. Hanna_ %o A140757 (Magma) %o A140757 A140756:=[(-1)^(n+k)*k: k in [1..n], n in [1..40]]; %o A140757 A140757:= func< n | (&+[A140756[j]: j in [1..n]]) >; %o A140757 [A140757(n): n in [1..100]]; // _G. C. Greubel_, Oct 21 2023 %o A140757 (SageMath) %o A140757 A140756=flatten([[(-1)^(n+k)*k for k in range(1,n+1)] for n in range(1,41)]) %o A140757 def A140757(n): return sum(A140756[j] for j in range(n)) %o A140757 [A140757(n) for n in range(1,101)] # _G. C. Greubel_, Oct 21 2023 %o A140757 (Python) %o A140757 from math import comb, isqrt %o A140757 def A140757(n): return ((a-1)**2>>2)+(c>>1) if (c:=(a:=(m:=isqrt(k:=n<<1))+(k>m*(m+1)))-(b:=n-comb(a,2)))&1 else ((a+1)**2>>2)-(c>>1) # _Chai Wah Wu_, Jun 09 2025 %Y A140757 Cf. A002620, A140756. %K A140757 easy,nonn,tabl %O A140757 1,3 %A A140757 _Franklin T. Adams-Watters_, May 27 2008