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.

A057944 Largest triangular number less than or equal to n; write m-th triangular number m+1 times.

This page as a plain text file.
%I A057944 #48 Nov 09 2024 00:46:46
%S A057944 0,1,1,3,3,3,6,6,6,6,10,10,10,10,10,15,15,15,15,15,15,21,21,21,21,21,
%T A057944 21,21,28,28,28,28,28,28,28,28,36,36,36,36,36,36,36,36,36,45,45,45,45,
%U A057944 45,45,45,45,45,45,55,55,55,55,55,55,55,55,55,55,55,66,66,66,66,66,66
%N A057944 Largest triangular number less than or equal to n; write m-th triangular number m+1 times.
%H A057944 Reinhard Zumkeller, <a href="/A057944/b057944.txt">Rows n = 0..100 of triangle, flattened</a>
%F A057944 a(n) = floor((sqrt(1+8*n)-1)/2)*floor((sqrt(1+8*n)+1)/2)/2 = (trinv(n)*(trinv(n)-1))/2 = A000217(A003056(n)) = n - A002262(n)
%F A057944 a(n) = (1/2)*t*(t-1), where t = floor(sqrt(2*n+1)+1/2) = A002024(n+1). - _Ridouane Oudra_, Oct 20 2019
%F A057944 Sum_{n>=1} 1/a(n)^2 = 2*Pi^2/3 - 4. - _Amiram Eldar_, Aug 14 2022
%e A057944 a(35) = 28 since 28 and 36 are successive triangular numbers and 28 <= 35 < 36.
%p A057944 A057944 := proc(n)
%p A057944         k := (-1+sqrt(1+8*n))/2 ;
%p A057944         k := floor(k) ;
%p A057944         k*(k+1)/2 ;
%p A057944 end proc; # _R. J. Mathar_, Nov 05 2011
%t A057944 f[n_] := Block[{a = Floor@ Sqrt[1 + 8 n]}, Floor[(a - 1)/2]*Floor[(a + 1)/2]/2]; Array[f, 72, 0]
%t A057944 t0=0; t1=1; k=1; Table[If[n < t1, t0, k++; t0=t1; t1=t1+k; t0], {n, 0, 72}]
%t A057944 With[{nn=15},Table[#[[1]],#[[2]]+1]&/@Thread[{Accumulate[Range[ 0,nn]],Range[ 0,nn]}]]//Flatten (* _Harvey P. Dale_, Mar 01 2020 *)
%o A057944 (Haskell)
%o A057944 a057944 n = a057944_list !! n          -- common flat access
%o A057944 a057944_list = concat a057944_tabl
%o A057944 a057944' n k = a057944_tabl !! n !! k  -- access when seen as a triangle
%o A057944 a057944_row n = a057944_tabl !! n
%o A057944 a057944_tabl = zipWith ($) (map replicate [1..]) a000217_list
%o A057944 -- _Reinhard Zumkeller_, Feb 03 2012
%o A057944 (PARI) a(n)=my(t=(sqrtint(8*n+7)-1)\2);t*(t+1)/2 \\ _Charles R Greathouse IV_, Jan 26 2013
%o A057944 (Python)
%o A057944 from math import comb, isqrt
%o A057944 def A057944(n): return comb((m:=isqrt(k:=n+1<<1))+(k>m*(m+1)),2) # _Chai Wah Wu_, Nov 09 2024
%Y A057944 Cf. A000217, A003056, A056944, A057945, A127739.
%K A057944 easy,nonn,tabl
%O A057944 0,4
%A A057944 _Henry Bottomley_, Oct 05 2000
%E A057944 Keyword tabl added by _Reinhard Zumkeller_, Feb 03 2012