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.

Showing 1-7 of 7 results.

A220075 Partial sums in rows of A220073, triangle read by rows.

Original entry on oeis.org

1, 1, 3, 2, 3, 6, 3, 4, 6, 10, 4, 6, 7, 10, 15, 5, 8, 9, 11, 15, 21, 6, 10, 12, 13, 16, 21, 28, 7, 12, 15, 16, 18, 22, 28, 36, 8, 14, 18, 20, 21, 24, 29, 36, 45, 9, 16, 21, 24, 25, 27, 31, 37, 45, 55, 10, 18, 24, 28, 30, 31, 34, 39, 46, 55, 66, 11, 20, 27
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 03 2012

Keywords

Comments

T(n,k) = sum(A220073(n,i): i=1..k).

Crossrefs

Cf. A000027 (left edge), A000217 (right edge), A002061 (central terms), A019298 (row sums); A220053.

Programs

  • Haskell
    a220075 n k = a220075_tabl !! (n-1) !! (k-1)
    a220075_row n = a220075_tabl !! (n-1)
    a220075_tabl = map (scanl1 (+)) a220073_tabl
  • Mathematica
    A[n_, k_] := If[k == 1, n, If[k == n, n-1, Abs[2k-n-If[2k <= n+1, 2, 1]]]];
    A220073[n_, k_] := A[n, n-k+1];
    T[n_, k_] := Sum[A220073[n, i], {i, 1, k}];
    Table[T[n, k], {n, 1, 12}, {k, 1, n}] // Flatten (* Jean-François Alcover, Sep 27 2021 *)

A130517 Triangle read by rows: row n counts down from n in steps of 2, then counts up the remaining elements in the set {1,2,...,n}, again in steps of 2.

Original entry on oeis.org

1, 2, 1, 3, 1, 2, 4, 2, 1, 3, 5, 3, 1, 2, 4, 6, 4, 2, 1, 3, 5, 7, 5, 3, 1, 2, 4, 6, 8, 6, 4, 2, 1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 12, 10
Offset: 1

Views

Author

Omar E. Pol, Aug 08 2007

Keywords

Comments

Triangle read by rows in which row n lists the number of pairs of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order.
Row n lists a permutation of the first n positive integers.
If n is odd then row n lists the first (n+1)/2 odd numbers in decreasing order together with the first (n-1)/2 positive even numbers.
If n is even then row n lists the first n/2 even numbers in decreasing order together with the first n/2 odd numbers.
Row n >= 2, with its floor(n/2) last numbers taken as negative, lists the n different eigenvalues (in decreasing order) of the odd graph O(n). The odd graph O(n) has the (n-1)-subsets of a (2*n-1)-set as vertices, with two (n-1)-subsets adjacent if and only if they are disjoint. For example, O(3) is isomorphic to the Petersen graph. - Miquel A. Fiol, Apr 07 2024

Examples

			A geometric model of the atomic nucleus:
......-------------------------------------------------
......|...-----------------------------------------...|
......|...|...---------------------------------...|...|
......|...|...|...-------------------------...|...|...|
......|...|...|...|...-----------------...|...|...|...|
......|...|...|...|...|...---------...|...|...|...|...|
......|...|...|...|...|...|...-...|...|...|...|...|...|
......i...h...g...f...d...p...s...p...d...f...g...h...i
......|...|...|...|...|...|.......|...|...|...|...|...|
......|...|...|...|...|.......1.......|...|...|...|...|
......|...|...|...|.......2.......1.......|...|...|...|
......|...|...|.......3.......1.......2.......|...|...|
......|...|.......4.......2.......1.......3.......|...|
......|.......5.......3.......1.......2.......4.......|
..........6.......4.......2.......1.......3.......5....
......7.......5.......3.......1.......2.......4.......6
.......................................................
...13/2.11/2.9/2.7/2.5/2.3/2.1/2.1/2.3/2.5/2.7/2.9/2.11/2
......|...|...|...|...|...|...|...|...|...|...|...|...|
......|...|...|...|...|...|...-----...|...|...|...|...|
......|...|...|...|...|...-------------...|...|...|...|
......|...|...|...|...---------------------...|...|...|
......|...|...|...-----------------------------...|...|
......|...|...-------------------------------------...|
......|...---------------------------------------------
.
Triangle begins:
   1;
   2, 1;
   3, 1, 2;
   4, 2, 1, 3;
   5, 3, 1, 2, 4;
   6, 4, 2, 1, 3, 5;
   7, 5, 3, 1, 2, 4, 6;
   8, 6, 4, 2, 1, 3, 5, 7;
   9, 7, 5, 3, 1, 2, 4, 6, 8;
  10, 8, 6, 4, 2, 1, 3, 5, 7, 9;
  ...
Also:
                     1;
                   2,  1;
                 3,  1,  2;
               4,  2,  1,  3;
             5,  3,  1,  2,  4;
           6,  4,  2,  1,  3,  5;
         7,  5,  3,  1,  2,  4,  6;
       8,  6,  4,  2,  1,  3,  5,  7;
     9,  7,  5,  3,  1,  2,  4,  6,  8;
  10,  8,  6,  4,  2,  1,  3,  5,  7,  9;
  ...
In this view each column contains the same numbers.
From _Miquel A. Fiol_, Apr 07 2024: (Start)
Eigenvalues of the odd graphs O(n) for n=2..10:
   2, -1;
   3,  1, -2;
   4,  2, -1, -3;
   5,  3,  1, -2, -4;
   6,  4,  2, -1, -3, -5;
   7,  5,  3,  1, -2, -4, -6;
   8,  6,  4,  2, -1, -3, -5, -7;
   9,  7,  5,  3,  1, -2, -4, -6, -8;
  10,  8,  6,  4,  2, -1, -3, -5, -7, -9;
... (End)
		

Crossrefs

Absolute values of A056951. Column 1 is A000027. Row sums are in A000217.
Other versions are A004736, A212121, A213361, A213371.
Cf. A028310 (right edge), A000012 (central terms), A220073 (mirrored), A220053 (partial sums in rows), A375303.

Programs

  • Haskell
    a130517 n k = a130517_tabl !! (n-1) !! (k-1)
    a130517_row n = a130517_tabl !! (n-1)
    a130517_tabl = iterate (\row -> (head row + 1) : reverse row) [1]
    -- Reinhard Zumkeller, Dec 03 2012
    
  • Maple
    A130517 := proc(n,k)
         if k <= (n+1)/2 then
            n-2*(k-1) ;
        else
            1-n+2*(k-1) ;
        end if;
    end proc: # R. J. Mathar, Jul 21 2012
  • Mathematica
    t[n_, 1] := n; t[n_, n_] := n-1; t[n_, k_] := Abs[2*k-n - If[2*k <= n+1, 2, 1]]; Table[t[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* Jean-François Alcover, Oct 03 2013, from abs(A056951) *)
  • PARI
    a130517_row(n) = my(v=vector(n), s=1, n1=0, n2=n+1); forstep(k=n, 1,-1, s=-s; if(s>0, n2--; v[n2]=k, n1++; v[n1]=k)); v \\ Hugo Pfoertner, Aug 26 2024

Formula

a(n) = A162630(n)/2. - Omar E. Pol, Sep 02 2012
T(1,1) = 1; for n > 1: T(n,1) = T(n-1,1)+1 and T(n,k) = T(n-1,n-k+1), 1 < k <= n. - Reinhard Zumkeller, Dec 03 2012
From Boris Putievskiy, Jan 16 2013: (Start)
a(n) = |2*A000027(n) - A003056(n)^2 - 2*A003056(n) - 3| + floor((2*A000027(n) - A003056(n)^2 - A003056(n))/(A003056(n)+3)).
a(n) = |2*n - t^2 - 2*t - 3| + floor((2*n - t^2 - t)/(t+3)) where t = floor((-1+sqrt(8*n-7))/2). (End)

A143182 Triangle T(n,m) = 1 + abs(n-2*m), read by rows, 0<=m<=n.

Original entry on oeis.org

1, 2, 2, 3, 1, 3, 4, 2, 2, 4, 5, 3, 1, 3, 5, 6, 4, 2, 2, 4, 6, 7, 5, 3, 1, 3, 5, 7, 8, 6, 4, 2, 2, 4, 6, 8, 9, 7, 5, 3, 1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13
Offset: 0

Views

Author

Roger L. Bagula and Gary W. Adamson, Oct 17 2008

Keywords

Comments

From Boris Putievskiy, Jan 15 2013: (Start)
General case see A187760. Let m be natural number. Table T(n,k) n, k > 0, T(n,k)=n-k+1, if n>=k, T(n,k)=k-n+m-1, if n < k. Table T(n,k) read by antidiagonals. The first column of the table T(n,1) is the sequence of the natural numbers A000027. In all columns with number k (k > 1) the segment with the length of (k-1): {m+k-2, m+k-3, ..., m} shifts the sequence A000027. For m=1 the result is A220073, for m=2 the result is A143182. (End)

Examples

			From _Boris Putievskiy_, Jan 15 2013: (Start)
The start of the sequence as table:
1...2...3...4...5...6...7...8...9..10..11...
2...1...2...3...4...5...6...7...8...9..10...
3...2...1...2...3...4...5...6...7...8...9...
4...3...2...1...2...3...4...5...6...7...8...
5...4...3...2...1...2...3...4...5...6...7...
6...5...4...3...2...1...2...3...4...5...6...
7...6...5...4...3...2...1...2...3...4...5...
8...7...6...5...4...3...2...1...2...3...4...
9...8...7...6...5...4...3...2...1...2...3...
10..9...8...7...6...5...4...3...2...1...2...
11.10...9...8...7...6...5...4...3...2...1...
. . .
The start of the sequence as triangle array read by rows: (End)
   1;
   2, 2;
   3, 1, 3;
   4, 2, 2, 4;
   5, 3, 1, 3, 5;
   6, 4, 2, 2, 4, 6;
   7, 5, 3, 1, 3, 5, 7;
   8, 6, 4, 2, 2, 4, 6, 8;
   9, 7, 5, 3, 1, 3, 5, 7, 9;
  10, 8, 6, 4, 2, 2, 4, 6, 8, 10;
  11, 9, 7, 5, 3, 1, 3, 5, 7,  9, 11;
. . .
Row number r contains r numbers: r, r-2,...3,1,3,...r-2,r if r is odd,
r, r-2,...2,2,...r-2,r, if r is even. - _Boris Putievskiy_, Jan 15 2013
		

Crossrefs

Cf. A049581 (subtract 1's), A074148 (row sums), A000027, A220073, A187760.

Programs

  • GAP
    Flat(List([0..15], n-> List([0..n], k-> 1+AbsInt(n-2*k) ))); # G. C. Greubel, Jul 23 2019
  • Magma
    [1+Abs(n-2*k): k in [0..n], n in [0..15]]; // G. C. Greubel, Jul 23 2019
    
  • Mathematica
    T[n_, m_]:= 1+Abs[(1+n-m) - (1+m)]; Table[Table[t[n, m], {m,0,n}], {n, 0, 15}]//Flatten
  • PARI
    for(n=0,15, for(k=0,n, print1(1+abs(n-2*k), ", "))) \\ G. C. Greubel, Jul 23 2019
    
  • Sage
    [[1+abs(n-2*k) for k in (0..n)] for n in (0..15)] # G. C. Greubel, Jul 23 2019
    

Formula

Symmetry: T(n,m) = T(n,n-m).
From Boris Putievskiy, Jan 15 2013: (Start)
For the general case
a(n) = |(t+1)^2 - 2n| + m*floor((t^2+3t+2-2n)/(t+1)),
where t = floor((-1+sqrt(8*n-7))/2).
For m = 2
a(n) = |(t+1)^2 - 2n| + 2*floor((t^2+3t+2-2n)/(t+1)),
where t=floor((-1+sqrt(8*n-7))/2). (End)

Extensions

Offset and row sums corrected by R. J. Mathar, Jul 05 2012

A187760 Table T(n,k) read by antidiagonals. T(n,k)=n-k+1, if n>=k, T(n,k)=k-n+2, if n < k.

Original entry on oeis.org

1, 3, 2, 4, 1, 3, 5, 3, 2, 4, 6, 4, 1, 3, 5, 7, 5, 3, 2, 4, 6, 8, 6, 4, 1, 3, 5, 7, 9, 7, 5, 3, 2, 4, 6, 8, 10, 8, 6, 4, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 2, 4, 6, 8, 10, 12, 10, 8, 6, 4, 1, 3, 5, 7, 9, 11
Offset: 1

Views

Author

Boris Putievskiy, Jan 04 2013

Keywords

Comments

In general, let m be natural number. T(n,k)=n-k+1, if n>=k, T(n,k)=k-n+m-1, if n A000027. In all columns with number k (k > 1) the segment with the length of (k-1): {m+k-2, m+k-3, ..., m} shifts the sequence A000027. For m=1 the result is A220073, for m=2 the result is A143182. This sequence is the result for m=3.

Examples

			The start of the sequence as table for the general case:
1....m..m+1..m+2..m+3..m+4..m+5...
2....1....m..m+1..m+2..m+3..m+4...
3....2....1....m..m+1..m+2..m+3...
4....3....2....1....m..m+1..m+2...
5....4....3....2....1....m..m+1...
6....5....4....3....2....1....m...
7....6....5....4....3....2....1...
. . .
The start of the sequence as triangle array read by rows for the general case:
1;
m,2;
m+1,1,3;
m+2,m,2,4;
m+3,m+1,1,3,5;
m+4,m+2,m,2,4,6;
m+5,m+3,m+1,1,3,5,7;
. . .
Row number r contains r numbers: m+r-2, m+r-4,...r-2,r.
		

Crossrefs

Programs

  • Mathematica
    T[n_, k_] := If[1 <= k <= n, n - k + 1, k - n + 2];
    Table[T[n - k + 1, k], {n, 1, 11}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Nov 06 2018 *)
  • Python
    t=int((math.sqrt(8*n-7)-1)/2)
    result=abs((t+1)**2 - 2*n) + 3*int((t**2+3*t+2-2*n)/(t+1))

Formula

For the general case, a(n) = |(t+1)^2 - 2n| + m*floor((t^2+3t+2-2n)/(t+1)), where t=floor((-1+sqrt(8*n-7))/2).
For m=3, a(n) = |(t+1)^2 - 2n| + 3*floor((t^2+3t+2-2n)/(t+1)), where t=floor((-1+sqrt(8*n-7))/2).

A210535 Second inverse function (numbers of columns) for pairing function A209293.

Original entry on oeis.org

1, 2, 1, 2, 3, 1, 2, 4, 3, 1, 2, 4, 5, 3, 1, 2, 4, 6, 5, 3, 1, 2, 4, 6, 7, 5, 3, 1, 2, 4, 6, 8, 7, 5, 3, 1, 2, 4, 6, 8, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12
Offset: 1

Views

Author

Boris Putievskiy, Jan 28 2013

Keywords

Examples

			The start of the sequence as triangle array read by rows:
  1;
  2,1;
  2,3,1;
  2,4,3,1;
  2,4,5,3,1;
  2,4,6,5,3,1;
  2,4,6,7,5,3,1;
  2,4,6,8,7,5,3,1;
  . . .
Row number r contains permutation numbers from 1 to r: 2,4,6,...2*floor(r/2),2*floor(r/2)-1,2*floor(r/2)-3,...3,1.
		

Crossrefs

Programs

  • Python
    t=int((math.sqrt(8*n-7)-1)/2)
    i=n-t*(t+1)/2
    v=int((2*n+1-t*(t+1))/(t+3))
    result=2*i-v*(4*i-2*t-3)

Formula

a(n) = 2*A200260(n)-A101688(n)*(4*A002260(n)-2*A003056(n)-3).
a(n) = 2*i-v*(4*i-2*t-3), where t = floor((-1+sqrt(8*n-7))/2), i = n-t*(t+1)/2, v = floor((2*n+1-t*(t+1))/(t+3)).

A355792 Triangular array, read by rows. The rules of the construction are described in the Comments section.

Original entry on oeis.org

1, 1, 2, 2, 3, 1, 1, 2, 4, 3, 3, 1, 2, 4, 5, 5, 6, 3, 1, 2, 4, 4, 5, 6, 3, 1, 7, 2, 2, 4, 5, 8, 6, 3, 1, 7, 7, 2, 4, 5, 8, 6, 3, 1, 9, 9, 10, 7, 2, 4, 5, 8, 6, 3, 1, 1, 9, 11, 10, 7, 2, 4, 5, 8, 6, 3, 3, 1, 9, 11, 12, 10, 7, 2, 4, 5, 8, 6, 6, 3, 1, 9, 11, 12, 10, 13, 7, 2
Offset: 1

Views

Author

Tamas Sandor Nagy, Jul 17 2022

Keywords

Comments

Row m contains m distinct elements of the set {1..m}. The last element k(m) in row m becomes the first one in row m+1. There, the remaining elements of row m repeat in the same order, with element m+1 inserted immediately after that which is the k(m)-th in row m.

Examples

			Triangle begins
  1;
  1,  2;
  2,  3,  1;
  1,  2,  4,  3;
  3,  1,  2,  4,  5;
  5,  6,  3,  1,  2,  4;
  4,  5,  6,  3,  1,  7,  2;
  2,  4,  5,  8,  6,  3,  1,  7;
  7,  2,  4,  5,  8,  6,  3,  1,  9;
  9, 10,  7,  2,  4,  5,  8,  6,  3,  1;
  1,  9, 11, 10,  7,  2,  4,  5,  8,  6,  3;
  3,  1,  9, 11, 12, 10,  7,  2,  4,  5,  8,  6;
  6,  3,  1,  9, 11, 12, 10, 13,  7,  2,  4,  5,  8;
  ...
To illustrate the rule:
Row 6 ends with 4, therefore the next row, row 7, begins with 4.
The order of the rest of the elements in row 6, that is, 5, 6, 3, 1, and 2, remains unchanged in row 7, while there the new element 7 is introduced immediately after 1 since the 4th element in row 6 is 1.
From _Jon E. Schoenfield_, Jul 17 2022: (Start)
The diagram below illustrates the way in which, on each row, each number from the previous row is placed either to the left or the right of the new number (which is identified by parentheses):
.
                                             (1)
.
                                            1  (2)
                                             \
                                      2  (3)  1
                                     /     \
                                1   2  (4)  3
                               /   /   /
                          3   1   2   4  (5)
                           \   \   \   \
                    5  (6)  3   1   2   4
                   /   /   /   /     \
              4   5   6   3   1  (7)  2
             /   /     \   \   \   \
        2   4   5  (8)  6   3   1   7
       /   /   /   /   /   /   /
  7   2   4   5   8   6   3   1  (9)
(End)
		

Crossrefs

Programs

  • MATLAB
    function a = A355792( max_row )
        T = cell(1,1); T{1} = 1;
        for n = 2:max_row
            j = mod(T{n-1}(end),n-1);
            s = circshift(T{n-1},1,2);
            T{n} = [s(1:j+1) n s(j+2:end)];
        end
        a = [T{1:end}];
    end % Thomas Scheuerle, Jul 18 2022

Formula

From Jon E. Schoenfield, Jul 17 2022: (Start)
T(1, 1) = 1.
For n > 1, let j = 2 + (T(n-1, n-1) mod (n-1)); then
T(n, k) = T(n-1, n-1) if k = 1
= T(n-1, k-1) if 1 < k < j
= n if k = j
= T(n-1, k-2) otherwise. (End)
Let b(n) = max(a(1),a(2),...,a(n)) then -(1/2) < 2^(1/2)*n^(1/2)-b(n) < (1/2). - Thomas Scheuerle, Jul 18 2022

A346036 Number of swaps needed to return the recursive transform T(k) = concatenate(reverse(k), len(k) + 1) to the tuple 1, 2, ..., n.

Original entry on oeis.org

0, 0, 1, 2, 2, 4, 5, 4, 6, 8, 7, 10, 10, 10, 13, 12, 12, 14, 17, 16, 18, 18, 17, 22, 22, 20, 25, 24, 24, 28, 29, 24, 26, 32, 31, 34, 32, 32, 35, 38, 36, 40, 35, 40, 40, 40, 39, 44, 46, 42, 49, 50, 44, 52, 51, 52, 52, 54, 51, 54, 58, 56, 59, 54, 54, 64, 61, 60
Offset: 1

Views

Author

Emanuel Landeholm, Jul 02 2021

Keywords

Examples

			For n=7, the T transforms give tuple 6,4,2,1,3,5,7 (triangle A220073 row 7) which requires a(7) = 5 swaps to return to 1,2,3,4,5,6,7.
		

Crossrefs

Cf. A220073.

Programs

  • PARI
    a(n) = my(h=n>>1); n - #permcycles(vectorsmall(n,i, abs(2*i-n) + (i<=h))); \\ Kevin Ryde, Jul 23 2021
  • Python
    def swaps(l, start = 0):
      if len(l) == 0:
        return 0
      n = start + 1
      if l[0] != n:
        for i, x in enumerate(l):
          if x == n:
            l[0], l[i] = l[i], l[0]
            return 1 + swaps(l[1:], n)
        else:
          raise
      else:
        return swaps(l[1:], n)
    def T(l):
      n = len(l)
      l.reverse()
      l.append(n + 1)
      return l
    if _name_ == "_main_":
      l = [ ]
      for n in range(1, 100):
        l = T(l)
        n_swaps = swaps(l[:])
        print("{}, ".format(n_swaps), end="")
    
Showing 1-7 of 7 results.