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.

A157454 Triangle read by rows: T(n, m) = min(2*m - 1, 2*(n - m) + 1).

Original entry on oeis.org

1, 1, 1, 1, 3, 1, 1, 3, 3, 1, 1, 3, 5, 3, 1, 1, 3, 5, 5, 3, 1, 1, 3, 5, 7, 5, 3, 1, 1, 3, 5, 7, 7, 5, 3, 1, 1, 3, 5, 7, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1
Offset: 1

Views

Author

Roger L. Bagula, Mar 01 2009

Keywords

Examples

			Triangle starts:
  1;
  1,  1;
  1,  3,  1;
  1,  3,  3,  1;
  1,  3,  5,  3,  1;
  1,  3,  5,  5,  3,  1;
  1,  3,  5,  7,  5,  3,  1;
  1,  3,  5,  7,  7,  5,  3,  1;
  1,  3,  5,  7,  9,  7,  5,  3,  1;
  1,  3,  5,  7,  9,  9,  7,  5,  3,  1;
  1,  3,  5,  7,  9, 11,  9,  7,  5,  3,  1;
  ...
		

Crossrefs

Row sums are A000982(n).

Programs

  • GAP
    Flat(List([1..12], n-> List([1..n], k-> Minimum(2*k-1, 2*(n-k)+1) ))); # G. C. Greubel, Jun 30 2019
    
  • Haskell
    import Data.List (inits)
    a157454 n k = a157454_tabl !! (n-1) !! (k-1)
    a157454_row n = a157454_tabl !! (n-1)
    a157454_tabl = concatMap h $ tail $ inits [1, 3 ..] where
       h xs = [xs ++ tail xs', xs ++ xs'] where xs' = reverse xs
    -- Reinhard Zumkeller, Dec 15 2013
    
  • Magma
    [[Min(2*k-1, 2*(n-k)+1): k in [1..n]]: n in [1..12]]; // G. C. Greubel, Jun 30 2019
    
  • Mathematica
    Table[Min[2*k-1, 2*(n-k)+1], {n,1,12}, {k,1,n}]//Flatten (* modified by G. C. Greubel, Jun 30 2019 *)
  • PARI
    {T(n,k) = min(2*k-1, 2*(n-k)+1)};
    for(n=1,12, for(k=1,n, print1(T(n,k), ", "))) \\ G. C. Greubel, Jun 30 2019
    
  • Python
    from math import isqrt
    def A157454(n): return (isqrt(n<<3)+1>>1)-abs((k:=n<<1)-((m:=isqrt(k))+(k>m*(m+1)))**2-1) # Chai Wah Wu, Jun 08 2025
  • Sage
    [[min(2*k-1, 2*(n-k)+1) for k in (1..n)] for n in (1..12)] # G. C. Greubel, Jun 30 2019
    

Formula

T(n,m) = T(n,n-m) = 2*m-1 for 0 <= m <= n/2, otherwise 2*(n-m)+1.
a(n) = 2*A003983(n) - 1.
From Ridouane Oudra, Jul 20 2019: (Start)
a(n) = A002024(n) - A049581(n-1).
a(n) = t - abs(t^2-2n+1), where t = floor(sqrt(2n)+1/2). (End)

Extensions

Edited by the Associate Editors of the OEIS, Apr 10 2009