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.

A038722 Take the sequence of natural numbers (A000027) and reverse successive subsequences of lengths 1,2,3,4,... .

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, May 02 2000

Keywords

Comments

Ramanujan theta functions: f(q) (see A121373), phi(q) (A000122), psi(q) (A010054), chi(q) (A000700).
The rectangular array having A038722 as antidiagonals is the transpose of the rectangular array given by A000217. Column 1 of array A038722 is A000124 (central polygonal numbers). Array A038722 is the dispersion of the complement of A000124. - Clark Kimberling, Apr 05 2003
a(n) is the smallest number not yet in the sequence such that n + a(n) is one more than a square. - Franklin T. Adams-Watters, Apr 06 2009
From Hieronymus Fischer, Apr 30 2012: (Start)
A reordering of the natural numbers.
The sequence is self-inverse in that a(a(n)) = n.
Also: a(1) = 1, a(n) = m (where m is the least triangular number > a(k) for 1 <= k < n), if the minimal natural number not yet in the sequence is greater than a(n-1), otherwise a(n) = a(n-1)-1. (End)

Examples

			The rectangular array view is
   1    2    4    7   11   16   22   29   37   46
   3    5    8   12   17   23   30   38   47   57
   6    9   13   18   24   31   39   48   58   69
  10   14   19   25   32   40   49   59   70   82
  15   20   26   33   41   50   60   71   83   96
  21   27   34   42   51   61   72   84   97  111
  28   35   43   52   62   73   85   98  112  127
  36   44   53   63   74   86   99  113  128  144
  45   54   64   75   87  100  114  129  145  162
  55   65   76   88  101  115  130  146  163  181
		

References

  • Suggested by correspondence with Michael Somos.
  • R. Honsberger, "Ingenuity in Mathematics", Table 10.4 on page 87.

Crossrefs

A self-inverse permutation of the natural numbers.
Cf. A056011 (boustrophedon).
Cf. A061579.

Programs

  • Haskell
    a038722 n = a038722_list !! (n-1)
    a038722_list = concat a038722_tabl
    a038722_tabl = map reverse a000027_tabl
    a038722_row n = a038722_tabl !! (n-1)
    -- Reinhard Zumkeller, Nov 08 2013
  • Mathematica
    (* Program generates dispersion array T of the increasing sequence f[n] *)
    r=40; r1=12; c=40; c1=12; f[n_] := Floor[n+1/2+Sqrt[2n]]
      (* complement of column 1 *)
    mex[list_] := NestWhile[#1 + 1 &, 1, Union[list][[#1]] <= #1 &, 1, Length[Union[list]]]
    rows = {NestList[f, 1, c]};
    Do[rows = Append[rows, NestList[f, mex[Flatten[rows]], r]], {r}];
    t[i_, j_] := rows[[i, j]];
    TableForm[Table[t[i, j], {i, 1, r1}, {j, 1, c1}]]
    (* A038722 array *)
    Flatten[Table[t[k, n - k + 1], {n, 1, c1}, {k, 1, n}]] (* A038722 sequence *)
     (* Clark Kimberling, Jun 06 2011, corrected Jan 26 2025 *)
    Table[ n, {m, 12}, {n, m (m + 1)/2, m (m - 1)/2 + 1, -1}] // Flatten (* or *)
    Table[ Ceiling[(Sqrt[8 n + 1] - 1)/2]^2 - n + 1, {n, 78}] (* Robert G. Wilson v, Jun 27 2014 *)
    With[{nn=20},Reverse/@TakeList[Range[(nn(1+nn))/2],Range[nn]]//Flatten] (* Requires Mathematica version 11 or later *) (* Harvey P. Dale, Dec 14 2017 *)
  • PARI
    a(n)=local(t=floor(1/2+sqrt(2*n))); if(n<1, 0, t^2-n+1) /* Paul D. Hanna */
    

Formula

a(n) = (sqrt(2n-1) - 1/2)*(sqrt(2n-1) + 3/2) - n + 2 = A061579(n-1) + 1. Seen as a square table by antidiagonals, T(n, k) = k + (n+k-1)*(n+k-2)/2, i.e., the transpose of A000027 as a square table.
G.f.: g(x) = (x/(1-x))*(psi(x) - x/(1-x) + 2*Sum_{k>=0} k*x^(k*(k+1)/2)) where psi(x) = Sum_{k>=0} x^(k*(k+1)/2) = (1/2)*x^(-1/8)*theta_2(0,x^(1/2)) is a Ramanujan theta function. - Hieronymus Fischer, Aug 08 2007
a(n) = floor(sqrt(2*n) + 1/2)^2 - n + 1. - Clark Kimberling, Jun 05 2011; corrected by Paul D. Hanna, Jun 27 2011
From Hieronymus Fischer, Apr 30 2012: (Start)
a(n) = a(n-1)-1, if a(n-1)-1 > 0 is not in the set {a(k)| 1<=k
a(n) = n for n = 2k(k+1)+1, k >= 0.
a(n+1) = (m+2)(m+3)/2, if 8a(n)-7 is a square of an odd number, otherwise a(n+1) = a(n)-1, where m = (sqrt(8a(n)-7)-1)/2.
a(n) = ceiling((sqrt(8n+1)-1)/2)^2 - n + 1. (End)
G.f. as rectangular array: x*y*(1 - (1 + x)*y + (1 - x + x^2)*y^2)/((1 - x)^3*(1 - y)^3). - Stefano Spezia, Dec 25 2022