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.

Original entry on oeis.org

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, 21, 21, 28, 28, 28, 28, 28, 28, 28, 28, 36, 36, 36, 36, 36, 36, 36, 36, 36, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 66, 66, 66, 66, 66, 66
Offset: 0

Views

Author

Henry Bottomley, Oct 05 2000

Keywords

Examples

			a(35) = 28 since 28 and 36 are successive triangular numbers and 28 <= 35 < 36.
		

Crossrefs

Programs

  • Haskell
    a057944 n = a057944_list !! n          -- common flat access
    a057944_list = concat a057944_tabl
    a057944' n k = a057944_tabl !! n !! k  -- access when seen as a triangle
    a057944_row n = a057944_tabl !! n
    a057944_tabl = zipWith ($) (map replicate [1..]) a000217_list
    -- Reinhard Zumkeller, Feb 03 2012
    
  • Maple
    A057944 := proc(n)
            k := (-1+sqrt(1+8*n))/2 ;
            k := floor(k) ;
            k*(k+1)/2 ;
    end proc; # R. J. Mathar, Nov 05 2011
  • Mathematica
    f[n_] := Block[{a = Floor@ Sqrt[1 + 8 n]}, Floor[(a - 1)/2]*Floor[(a + 1)/2]/2]; Array[f, 72, 0]
    t0=0; t1=1; k=1; Table[If[n < t1, t0, k++; t0=t1; t1=t1+k; t0], {n, 0, 72}]
    With[{nn=15},Table[#[[1]],#[[2]]+1]&/@Thread[{Accumulate[Range[ 0,nn]],Range[ 0,nn]}]]//Flatten (* Harvey P. Dale, Mar 01 2020 *)
  • PARI
    a(n)=my(t=(sqrtint(8*n+7)-1)\2);t*(t+1)/2 \\ Charles R Greathouse IV, Jan 26 2013
    
  • Python
    from math import comb, isqrt
    def A057944(n): return comb((m:=isqrt(k:=n+1<<1))+(k>m*(m+1)),2) # Chai Wah Wu, Nov 09 2024

Formula

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)
a(n) = (1/2)*t*(t-1), where t = floor(sqrt(2*n+1)+1/2) = A002024(n+1). - Ridouane Oudra, Oct 20 2019
Sum_{n>=1} 1/a(n)^2 = 2*Pi^2/3 - 4. - Amiram Eldar, Aug 14 2022

Extensions

Keyword tabl added by Reinhard Zumkeller, Feb 03 2012