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-6 of 6 results.

A004738 Concatenation of sequences (1,2,...,n-1,n,n-1,...,2) for n >= 2.

Original entry on oeis.org

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

Views

Author

R. Muller

Keywords

Comments

Also concatenation of sequences n,n-1,...,2,1,2,...,n-1,n.
Table T(n,k) n, k > 0, T(n,k) = n-k+1, if n >= k, T(n,k) = k-n+1, if n < k. Table read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1). General case A209301. Let m be a natural number. 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 A004739, for m=2 the result is A004738, for m=3 the result is A209301. - Boris Putievskiy, Jan 24 2013

Examples

			From _Boris Putievskiy_, Jan 24 2013: (Start)
The start of the sequence as table:
  1, 2, 3, 4, 5, 6, 7, ...
  2, 1, 2, 3, 4, 5, 6, ...
  3, 2, 1, 2, 3, 4, 5, ...
  4, 3, 2, 1, 2, 3, 4, ...
  5, 4, 3, 2, 1, 2, 3, ...
  6, 5, 4, 3, 2, 1, 2, ...
  7, 6, 5, 4, 3, 2, 1, ...
  ...
The start of the sequence as triangle array read by rows:
  1;
  2, 1, 2;
  3, 2, 1, 2, 3;
  4, 3, 2, 1, 2, 3, 4;
  5, 4, 3, 2, 1, 2, 3, 4, 5;
  6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6;
  7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7;
  ...
Row number r contains 2*r - 1 numbers: r, r-1, ..., 1, 2, ..., r. (End)
		

References

  • F. Smarandache, "Numerical Sequences", University of Craiova, 1975; [ See Arizona State University, Special Collection, Tempe, AZ, USA ].

Crossrefs

Programs

  • Maple
    A004738 := proc(n)
        local tri ;
        tri := floor(sqrt(n)+1/2) ;
        tri+1-abs(n-1-tri^2) ;
    end proc:
    seq(A004738(n),n=1..30) ; #R. J. Mathar, Feb 14 2019
  • Mathematica
    row[n_] := Range[n, 1, -1] ~Join~ Range[2, n];
    Array[row, 10] // Flatten (* Jean-François Alcover, Apr 19 2020 *)
  • PARI
    a(n)= floor(sqrt(n)+1/2)+1-abs(n-1-(floor(sqrt(n)+1/2)-1/2)^2)
    
  • Python
    from math import isqrt
    def A004738(n): return abs((t:=isqrt(n-1))*(t+1)-n+1)+1 # Chai Wah Wu, Mar 01 2025

Formula

a(n) = floor(sqrt(n) + 1/2) + 1 - abs(n - 1 - (floor(sqrt(n) + 1/2))^2). - Benoit Cloitre, Feb 08 2003
From Boris Putievskiy, Jan 24 2013: (Start)
For the general case, a(n) = m*v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1.
For m=2, a(n) = 2*v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1. (End)

Extensions

More terms from Patrick De Geest, Jun 15 1998

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

A220073 Mirror of the triangle A130517.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Dec 03 2012

Keywords

Comments

T(n,k) = A130517(n,n-k+1), 1 <= k <= n;
T(n,n) = T(n,1) + 1.
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)
First inverse function (numbers of rows) for pairing function A209293. - Boris Putievskiy, Jan 28 2013

Examples

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

Crossrefs

Cf. A028310 (left edge), A000027 (right edge), A000012 (central terms), A000217 (row sums), A220075 (partial sums in rows), A002260, A000027, A143182, A187760, A209293.

Programs

  • Haskell
    a220073 n k = a220073_tabl !! (n-1) !! (k-1)
    a220073_row n = a220073_tabl !! (n-1)
    a220073_tabl = map reverse a130517_tabl
  • Mathematica
    max = 13;
    row[n_] := Join[Range[n, 1, -1], Range[max - n + 1]];
    T = Array[row, max];
    Table[T[[n - k + 1, k]], {n, 1, max}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Sep 11 2017 *)

Formula

T(1,1)=1, for n>1: T(n,k)=T(n-1,n-k+1), 1<=k
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| + floor((t^2+3t+2-2n)/(t+1)),
where t=floor((-1+sqrt(8*n-7))/2). (End)

A004739 Concatenation of sequences (1,2,2,...,n-1,n-1,n,n,n-1,n-1,...,2,2,1) for n >= 1.

Original entry on oeis.org

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

Author

R. Muller

Keywords

Comments

From Artur Jasinski, Mar 07 2010: (Start)
Zeta(2, k/p) + Zeta(2, (p-k)/p) = (Pi/sin((Pi*a(n))/p))*2, where p=2,3,4, k=1..p-1.
This sequence is the odd subset of A003983 for odd p=3,5,7,9,....
For the even subset of A003983 see A004737. (End)
Table T(n,k) n, k > 0, T(n,k) = n-k+1, if n >= k, T(n,k) = k-n, if n < k. Table read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1). General case A209301. Let m be a natural number. 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 A004739, for m=2 the result is A004738, for m=3 the result is A209301. - Boris Putievskiy, Jan 24 2013

Examples

			From _Boris Putievskiy_, Jan 24 2013: (Start)
The start of the sequence as table:
  1, 1, 2, 3, 4, 5, 6, ...
  2, 1, 1, 2, 3, 4, 5, ...
  3, 2, 1, 1, 2, 3, 4, ...
  4, 3, 2, 1, 1, 2, 3, ...
  5, 4, 3, 2, 1, 1, 2, ...
  6, 5, 4, 3, 2, 1, 1, ...
  7, 6, 5, 4, 3, 2, 1, ...
  ...
The start of the sequence as triangle array read by rows:
  1;
  1, 1, 2;
  2, 1, 1, 2, 3;
  3, 2, 1, 1, 2, 3, 4;
  4, 3, 2, 1, 1, 2, 3, 4, 5;
  5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6;
  6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7;
  ...
Row number r contains 2*r - 1 numbers: r-1, r-2, ..., 1, 1, 2, ..., r. (End)
		

Programs

  • Haskell
    a004739 n = a004739_list !! (n-1)
    a004739_list = concat $ map (\n -> [1..n] ++ [n,n-1..1]) [1..]
    -- Reinhard Zumkeller, Mar 26 2011
  • Mathematica
    aa = {}; Do[Do[AppendTo[aa, (p/Pi) ArcSin[Sqrt[1/((1/Pi^2) (Zeta[2, k/p] + Zeta[2, (p - k)/p]))]]], {k, 1, p - 1}], {p, 3, 50, 2}]; Round[N[aa, 50]] (* Artur Jasinski, Mar 07 2010 *)

Formula

From Boris Putievskiy, Jan 24 2013: (Start)
For the general case,
a(n) = m*v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1.
For m=1,
a(n) = v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1. (End)

Extensions

More terms from Patrick De Geest, Jun 15 1998

A209301 Table T(n,k) n, k > 0, T(n,k)=n-k+1, if n>=k, T(n,k)=k-n+2, if n < k. Table read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1).

Original entry on oeis.org

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

Author

Boris Putievskiy, Jan 18 2013

Keywords

Comments

In general, let m be natural number. 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 A004739, for m=2 the result is A004738. This sequence is 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,1,2;
  m+1,m,1,2,3;
  m+2,m+1,m,1,2,3,4;
  m+3,m+2,m+1,m,1,2,3,4,5;
  m+4, m+3,m+2,m+1,m,1,2,3,4,5,6;
  m+5, m+4, m+3,m+2,m+1,m,1,2,3,4,5,6,7;
  ...
Row number r contains 2*r -1 numbers: m+r-2, m+r-1,...m,1,2,...r.
The start of the sequence as triangle array read by rows for m=3:
  1;
  3,1,2;
  4,3,1,2,3;
  5,4,3,1,2,3,4;
  6,5,4,3,1,2,3,4,5;
  7,6,5,4,3,1,2,3,4,5,6;
  8,7,6,5,4,3,1,2,3,4,5,6,7;
  ...
		

Crossrefs

Programs

  • Python
    t=int((math.sqrt(n))-0.5)+1
    v=int((n-1)/t)-t+1
    result=k*v+(2*v-1)*(t**2-n)+t

Formula

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

A209302 Table T(n,k) = max{n+k-1, n+k-1} n, k > 0, read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1).

Original entry on oeis.org

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

Author

Boris Putievskiy, Jan 18 2013

Keywords

Examples

			The start of the sequence as a table for the general case:
      1   m+1 2*m+1 3*m+1 4*m+1 5*m+1 6*m+1 ...
    m+1   m+2 2*m+2 3*m+2 4*m+2 5*m+2 6*m+2 ...
  2*m+1 2*m+2 2*m+3 3*m+3 4*m+3 5*m+3 6*m+3 ...
  3*m+1 3*m+2 3*m+3 3*m+4 4*m+4 5*m+4 6*m+4 ...
  4*m+1 4*m+2 4*m+3 4*m+4 4*m+5 5*m+5 6*m+5 ...
  5*m+1 5*m+2 5*m+3 5*m+4 5*m+5 5*m+6 6*m+6 ...
  6*m+1 6*m+2 6*m+3 6*m+4 6*m+5 6*m+6 6*m+7 ...
  ...
The start of the sequence as a triangular array read by rows for general case:
      1;
    m+1,   m+2,   m+1;
  2*m+1, 2*m+2, 2*m+3, 2*m+2, 2*m+1;
  3*m+1, 3*m+2, 3*m+3, 3*m+4, 3*m+3, 3*m+2, 3*m+1;
  4*m+1, 4*m+2, 4*m+3, 4*m+4, 4*m+5, 4*m+4, 4*m+3, 4*m+2, 4*m+1;
  ...
Row r contains 2*r-1 terms: r*m+1, r*m+2, ... r*m+r, r*m+r+1, r*m+r, ..., r*m+2, r*m+1.
The start of the sequence as triangle array read by rows for m=1:
  1;
  2,  3,  2;
  3,  4,  5,  4,  3;
  4,  5,  6,  7,  6,  5,  4;
  5,  6,  7,  8,  9,  8,  7,  6,  5;
  6,  7,  8,  9, 10, 11, 10,  9,  8,  7,  6;
  7,  8,  9, 10, 11, 12, 13, 12, 11, 10,  9,  8,  7;
  ...
		

Crossrefs

Cf. A187760.

Programs

  • Python
    result = 2*int(math.sqrt(n-1)) - abs(n-int(math.sqrt(n-1))**2 - int(math.sqrt(n-1)) -1) +1
    
  • Python
    from math import isqrt
    def A209302(n): return (k:=(m:=isqrt(n))+(n-m*(m+1)>=1))+abs(k**2-n) # Chai Wah Wu, Jun 08 2025

Formula

In general, let m be a natural number. Table T(n,k) = max{m*n+k-m, n+m*k-m}. For the general case,
a(n) = (m+1)*sqrt(n-1) + 1 - |n - floor(sqrt(n-1))^2 - floor(sqrt(n-1))|.
For m=1,
a(n) = 2*sqrt(n-1) + 1 - |n - floor(sqrt(n-1))^2 - floor(sqrt(n-1))|.
a(n) = t + |t^2 - n|, where t = floor(sqrt(n)+1/2). - Ridouane Oudra, May 07 2019
Showing 1-6 of 6 results.