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-2 of 2 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

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

Views

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)
		

Crossrefs

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
Showing 1-2 of 2 results.