A131821 Triangle read by rows: row n consists of n followed by (n-2) ones then n.
1, 2, 2, 3, 1, 3, 4, 1, 1, 4, 5, 1, 1, 1, 5, 6, 1, 1, 1, 1, 6, 7, 1, 1, 1, 1, 1, 7, 8, 1, 1, 1, 1, 1, 1, 8, 9, 1, 1, 1, 1, 1, 1, 1, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 10, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14
Offset: 1
Examples
First few rows of the triangle are: 1; 2, 2; 3, 1, 3; 4, 1, 1, 4; 5, 1, 1, 1, 5; 6, 1, 1, 1, 1, 6; 7, 1, 1, 1, 1, 1, 7; ...
Programs
-
Maple
A131821 := proc(n,c) if c=1 or c=n then n ; else 1 ; fi ; end: for n from 1 to 16 do for c from 1 to n do printf("%d,",A131821(n,c)) ; od: od: # R. J. Mathar, May 30 2008
-
Mathematica
T[n_, k_] := If[k == 1 || k == n, n, 1]; Table[T[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* Jean-François Alcover, May 05 2023 *)
-
Maxima
T(n,k) := if k = 1 or k = n then n else 1$ create_list(T(n, k), n, 1, 12, k, 1, n); /* Franck Maminirina Ramaharo, Dec 19 2018 */
-
Python
from math import isqrt def A131821(n): return m+(k>r) if 0<=(k:=n<<1)-(r:=(m:=isqrt(k))*(m+1))<=2 or n<=2 else 1 # Chai Wah Wu, Nov 07 2024
Formula
T(n,1) = T(n,n) = n for n >= 1, and T(n,k) = 1 for 2 <= k <= n - 1, n >= 3.
From Franck Maminirina Ramaharo, Dec 19 2018: (Start)
G.f.: y*(x - 3*x^2*y^2 + (x^2 + x^3)*y^3)/((1 - y)^2*(1 - x*y)^2).
E.g.f.: (1 - x^2 +(x^2 + (x - x^2)*y)*exp(y) - (1 - (x - x^2)*y)*exp(x*y))/(1 - x). (End)
Extensions
More terms from R. J. Mathar, May 30 2008