%I #28 Nov 18 2024 07:34:52
%S 1,1,2,3,2,4,3,5,4,6,7,5,8,6,9,7,10,8,11,9,12,13,10,14,11,15,12,16,13,
%T 17,14,18,15,19,16,20,21,17,22,18,23,19,24,20,25,21,26,22,27,23,28,24,
%U 29,25,30,31,26,32,27,33,28,34,29,35,30,36,31,37,32
%N Triangle read by rows: T(n,k) = T(n,k-2) + 1 if n > 1 and 2 <= k <= n; T(0,0) = 1, T(1,0) = 1, T(1,1) = 2; if n > 1 is odd, then T(n,0) = T(n-1,n-2) + 1 and T(n,1) = T(n-1,n-1) + 1; if n > 1 is even, then T(n,0) = T(n-1,n-1) + 1 and T(n,1) = T(n-1,n-2) + 1.
%C As an array, for each m, row 2*m has m odd numbers and m+1 even numbers; row 2*m-1 has m odds and m evens. As a sequence, every positive integer n occurs exactly twice, separated by floor((n+1)/2) other numbers.
%H Reinhard Zumkeller, <a href="/A246694/b246694.txt">Rows n = 0..125 of triangle, flattened</a>
%F T(n, k) = 1 + floor(n/2) * (1+(-1)^k) / 2 + (floor(n/2))^2 + (2*k - 1 + (-1)^k) / 4 + (1-(-1)^n) * (1-(-1)^k) * n / 4. - _Werner Schulte_, Nov 16 2024
%F From _Stefano Spezia_, Nov 17 2024: (Start)
%F T(n, k) = (6 + (-1)^k + (-1)^(k+n) + 4*k + 2*n*(1 + (-1)^(k+n) + n))/8.
%F G.f.: (1 - x^3*y + x^7*y^3 + x^4*(1 - 2*y^2) - x^5*y*(1 - y^2))/((1 - x)^3*(1 + x)^2*(1 - x*y)^3*(1 + x*y)). (End)
%e First 8 rows:
%e 1
%e 1 ... 2
%e 3 ... 2 ... 4
%e 3 ... 5 ... 4 ... 6
%e 7 ... 5 ... 8 ... 6 ... 9
%e 7 .. 10 ... 8 .. 11 ... 9 .. 12
%e 13 .. 10 .. 14 .. 11 .. 15 .. 12 .. 16
%e 13 .. 17 .. 14 .. 18 .. 15 .. 19 .. 16 .. 20
%t z = 25; t[0, 0] = 1; t[1, 0] = 1; t[1, 1] = 2;
%t t[n_, 0] := If[OddQ[n], t[n - 1, n - 2] + 1, t[n - 1, n - 1] + 1];
%t t[n_, 1] := If[OddQ[n], t[n - 1, n - 1] + 1, t[n - 1, n - 2] + 1];
%t t[n_, k_] := t[n, k - 2] + 1; Flatten[Table[t[n, k], {n, 0, z}, {k, 0, n}]](*A246694*)
%o (Haskell)
%o a246694 n k = a246694_tabl !! n !! k
%o a246694_row n = a246694_tabl !! n
%o a246694_tabl = [1] : [1,2] : f 1 2 [1,2] where
%o f i z xs = ys : f j (z + 1) ys where
%o ys = take (z + 1) $ map (+ 1) (xs !! (z - i) : xs !! (z - j) : ys)
%o j = 3 - i
%o -- _Reinhard Zumkeller_, Sep 03 2014
%Y Cf. A246705, A246706, A246696.
%Y Cf. A246695 (row sums), A174114 (central terms).
%Y Cf. A002620 (main diagonal and first subdiagonal), A377802.
%K nonn,easy,tabl,changed
%O 0,3
%A _Clark Kimberling_, Sep 01 2014
%E Edited by _M. F. Hasler_, Nov 17 2014