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.

A385406 Triangle read by rows: T(n, k) = n*(n+1)/2 - floor((n-1)/2) - (-1)^k * floor(k/2).

Original entry on oeis.org

1, 3, 2, 5, 4, 6, 9, 8, 10, 7, 13, 12, 14, 11, 15, 19, 18, 20, 17, 21, 16, 25, 24, 26, 23, 27, 22, 28, 33, 32, 34, 31, 35, 30, 36, 29, 41, 40, 42, 39, 43, 38, 44, 37, 45, 51, 50, 52, 49, 53, 48, 54, 47, 55, 46, 61, 60, 62, 59, 63, 58, 64, 57, 65, 56, 66, 73, 72, 74, 71, 75, 70, 76, 69, 77, 68, 78, 67
Offset: 1

Views

Author

Werner Schulte, Jun 27 2025

Keywords

Comments

This triangle seen as a sequence yields a permutation of the natural numbers (A000027).

Examples

			Triangle T(n, k) for 1 <= k <= n starts:
n \k :   1   2   3   4   5   6   7   8   9  10  11  12  13
==========================================================
   1 :   1
   2 :   3   2
   3 :   5   4   6
   4 :   9   8  10   7
   5 :  13  12  14  11  15
   6 :  19  18  20  17  21  16
   7 :  25  24  26  23  27  22  28
   8 :  33  32  34  31  35  30  36  29
   9 :  41  40  42  39  43  38  44  37  45
  10 :  51  50  52  49  53  48  54  47  55  46
  11 :  61  60  62  59  63  58  64  57  65  56  66
  12 :  73  72  74  71  75  70  76  69  77  68  78  67
  13 :  85  84  86  83  87  82  88  81  89  80  90  79  91
  etc.
		

Crossrefs

Cf. A080827 (column 1), A128918 (main diagonal), A006003 (row sums), A213399.

Programs

  • Mathematica
    T[n_, k_] := n*(n+1)/2 - Floor[(n-1)/2] - (-1)^k*Floor[k/2]; Table[T[n, k], {n, 1, 12}, {k, 1, n}] // Flatten (* Amiram Eldar, Jun 28 2025 *)
  • PARI
    T(n, k) = n*(n+1)/2 - floor((n-1)/2) - (-1)^k * floor(k/2)

Formula

T(n, k) = T(n, k-1) - (-1)^k * (k-1) for 1 < k <= n with initial values T(n, 1) = n*(n+1)/2 - floor((n-1)/2) for n >= 1.
T(n, n) = n*(n+1)/2 + (1-n) * (1 - n mod 2) = A128918(n).
T(2*n-1, n) = 2*n^2 - 2*n + 1 - (-1)^n * floor(n/2) = A213399(n-1).