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 A309038 #71 Sep 11 2019 10:57:19 %S A309038 0,4,0,8,8,8,4,0,12,14,16,18,20,16,12,8,4,0,16,18,20,22,24,26,28,28, %T A309038 28,26,24,20,16,12,8,4,0,20,22,24,26,28,30,32,34,36,38,40,42,44,42,40, %U A309038 38,36,32,28,24,20,16,12,8,4,0,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,56,56,56,56,56,56,52,48,44,40,36,32,28,24,20,16,12,8,4,0 %N A309038 Irregular triangle T read by rows: given a square made of n^2 squares of unit area, T(n, k) is the longest perimeter that can be obtained by removing k of n^2 squares such that the modified figure remains connected and without holes (n >= 0 and 0 <= k <= n^2). %C A309038 All the terms of this sequence are even numbers (A005843). %C A309038 In the figure, two unit area squares can be connected in a corner or sideways. %C A309038 Every n-th row of the triangle is made of almost four successive finite arithmetic progressions characterized respectively by the following common differences: 2, 0, -2, -4. If we let h_i(n) be the number of first differences of i-th progression (i = 1,2,3,4), we have that 4*n + 2*h_1(n) - 2*h_3(n) - 4*h_4(n) = 0 and h_1(n) + h_2(n) + h_3(n) + h_4(n) = n^2. %F A309038 T(n, 0) = A008586(n). %F A309038 T(n, k) = 2*(2*n + k) for 0 <= k <= h_1(n), T(n, k) = 2*(2*n + h_1(n)) for h_1(n) <= k <= h_1(n) + h_2(n), T(n, k) = 2*(2*(n + h_1(n)) + h_2(n) - k) for h_1(n) + h_2(n) <= k <= h_1(n) + h_2(n) + h_3(n), T(n, k) = 2*(2*(n + h_2(n) - k) + 3*h_1(n) + h_3(n)), for h_1(n) + h_2(n) + h_3(n) <= k <= n^2, where h_4(n) = n for 0 <= n <= 2 and h_4(n) = (1/8)*(-29 + 12*n + 2*n^2 - 3*cos(n*Pi) - 12*sin(n*Pi/2)) for n > 2, h_3(n) = 2*delta(n, 4) - 4*delta(n, 1) + 1 - cos(n*Pi) + 2*sin(n*Pi/2) and delta(i, j) is the Kronecker delta, h_2(n) = 2*(delta(n, 2) + delta(n, 4)) for 0 <= n <= 4 and h_2(n) = (1/8)*(71 - 20*n + 2*n^2 + 25*cos(n*Pi) + 4*sin(n*Pi/2)) for n > 4, h_1(n) = n^2 - (h_1(n) + h_2(n) + h_3(n)). %e A309038 The triangle T(n, k) begins: %e A309038 ---+------------------------------------------------------------------- %e A309038 n\k| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 %e A309038 ---+------------------------------------------------------------------- %e A309038 0 | 0 %e A309038 1 | 4 0 %e A309038 2 | 8 8 8 4 0 %e A309038 3 | 12 14 16 18 20 16 12 8 4 0 %e A309038 4 | 16 18 20 22 24 26 28 28 28 26 24 20 16 12 8 4 0 %e A309038 ... %e A309038 Here are the values of h_i's for the first seven rows of the triangle T: %e A309038 n h_1(n) h_2(n) h_3(n) h_4(n) %e A309038 -------------------------------------- %e A309038 0 0 0 0 0 %e A309038 1 0 0 0 1 %e A309038 2 0 2 0 2 %e A309038 3 4 0 0 5 %e A309038 4 6 2 2 6 %e A309038 5 12 0 4 9 %e A309038 6 16 6 0 14 %e A309038 ... %e A309038 Illustrations for n = 4, k=0..15 by _Andrew Howroyd_, Sep 01 2019: (Start) %e A309038 __.__.__.__ __.__.__.__ __.__.__.__ __.__.__.__ %e A309038 | | | | | | | | %e A309038 | | |__ | |__ | |__ __| %e A309038 | | __| | __|__ | __|__ |__ %e A309038 |__.__.__.__| |__.__.__.__| |__| |__.__| |__| |__.__| %e A309038 (16) (18) (20) (22) %e A309038 __.__.__.__ __. .__.__ __ __.__ __ __.__ %e A309038 | | | |__| | | | | | | | | __| %e A309038 |__ __.__| |__ __.__| |__|__|__.__| |__|__|__| %e A309038 __|__|__.__ __|__|__.__ __|__|__.__ __|__|__.__ %e A309038 |__| |__.__| |__| |__.__| |__| |__.__| |__| |__.__| %e A309038 (24) (26) (28) (28) %e A309038 __ __ __ __ %e A309038 | | __|__| __ __|__| __ __|__| __ __ %e A309038 |__|__|__| |__|__|__| |__|__|__| |__|__|__| %e A309038 __|__|__.__ __|__|__.__ __|__|__ __|__|__ %e A309038 |__| |__.__| |__| |__.__| |__| |__| |__| |__| %e A309038 (28) (26) (24) (20) %e A309038 __ __ __ %e A309038 |__|__|__| __|__| __ __ %e A309038 __|__| __|__| __|__| |__| %e A309038 |__| |__| |__| %e A309038 (16) (12) (8) (4) %e A309038 (End) %t A309038 h4[n_]:=If[n>2,(1/8)(-29+12n+2n^2-3*Cos[n*Pi]-12*Sin[n*Pi/2]),n]; h3[n_]:=1-Cos[n*Pi]-4*KroneckerDelta[n,1]+2*KroneckerDelta[n,4]+2*Sin[n*Pi/2]; h2[n_]:=If[n>4,(1/8)(71-20n+2n^2+25Cos[n*Pi]+4Sin[n*Pi/2]),2*(KroneckerDelta[n,2]+KroneckerDelta[n,4])]; h1[n_]:=n^2-(h2[n]+h3[n]+h4[n]); T[n_,k_]:=If[0<=k<=h1[n],2(2n+k),If[h1[n]<k<=(h1[n]+h2[n]),2(2n+h1[n]),If[(h1[n]+h2[n])<k<=(h1[n]+h2[n]+h3[n]),2(2(n+h1[n])+h2[n]-k),2(2(n+h2[n]-k)+3h1[n]+h3[n])]]]; Flatten[Table[T[n,k],{n,0,6},{k,0,n^2}]] %Y A309038 Cf. A000290, A005843, A008586, A048759, A326118 (h_4). %K A309038 nonn,tabf %O A309038 0,2 %A A309038 _Stefano Spezia_, Jul 08 2019