A038722 Take the sequence of natural numbers (A000027) and reverse successive subsequences of lengths 1,2,3,4,... .
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
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.
Links
- Hieronymus Fischer, Table of n, a(n) for n = 1..11401
- Michael Somos, Introduction to Ramanujan theta functions
- Eric Weisstein's World of Mathematics, Ramanujan Theta Functions
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
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
A132666 a(1)=1, a(n) = 2*a(n-1) if the minimal positive integer not yet in the sequence is greater than a(n-1), else a(n) = a(n-1)-1.
1, 2, 4, 3, 6, 5, 10, 9, 8, 7, 14, 13, 12, 11, 22, 21, 20, 19, 18, 17, 16, 15, 30, 29, 28, 27, 26, 25, 24, 23, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85
Offset: 1
Comments
Also: a(1)=1, a(n) = maximal positive number < a(n-1) not yet in the sequence, if it exists, else a(n) = 2*a(n-1).
Also: a(1)=1, a(n) = a(n-1)-1, if a(n-1) - 1 > 0 and has not been encountered so far, else a(n) = 2*a(n-1).
A reordering of the natural numbers. The sequence is self-inverse in that a(a(n)) = n.
Almost certainly a duplicate of A132340. - R. J. Mathar, Jun 12 2008
Links
Crossrefs
Programs
-
Haskell
import Data.List (delete) a132666 n = a132666_list !! (n-1) a132666_list = 1 : f 1 [2..] where f z xs = y : f y (delete y xs) where y | head xs > z = 2 * z | otherwise = z - 1 -- Reinhard Zumkeller, Sep 17 2001
-
Mathematica
max = 72; f[x_] := Sum[x^(2^k), {k, 0, Ceiling[ Log[2, max]]}]; g[x_] = (x (1 - 2x)/(1 - x) + 2x^2*f'[x^3] + 3/4*(f'[x] - 2x - 1))/(1 - x); Drop[ CoefficientList[ Series[ g[x], {x, 0, max}], x], 1] (* Jean-François Alcover, Dec 01 2011 *)
Formula
G.f.: g(x) = (x(1-2x)/(1-x) + 2x^2*f'(x^3) + 3/4*(f'(x)-2x-1))/(1-x) where f(x) = Sum_{k>=0} x^(2^k) and f'(z) = derivative of f(x) at x = z.
a(n) = 5*2^(r/2) - 3 - n, if both r and s are even, else a(n) = 7*2^((s-1)/2) - 3 - n, where r = ceiling(2*log_2((n+2)/3)) and s = ceiling(2*log_2((n+2)/2) - 1).
a(n) = 2^floor(1 + (k+1)/2) + 3*2^floor(k/2) - 3 - n, where k=r, if r is even, else k=s (with respect to r and s above; formally, k = ((r+s) + (r-s)*(-1)^r)/2).
A132674 a(1)=1, a(n) = 10*a(n-1) if the minimal positive integer not yet in the sequence is greater than a(n-1), else a(n) = a(n-1) - 1.
1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62
Offset: 1
Keywords
Comments
Also: a(1)=1, a(n) = maximal positive integer < a(n-1) not yet in the sequence, if it exists, else a(n) = 10*a(n-1).
Also: a(1)=1, a(n) = a(n-1) - 1, if a(n-1) - 1 > 0 and has not been encountered so far, else a(n) = 10*a(n-1).
A permutation of the positive integers. The sequence is self-inverse, in that a(a(n)) = n.
Crossrefs
Formula
The following formulas are given for a general parameter p > 2 considering the recurrence rule above (i.e., a(n) = p*a(n-1)...; p=10 for this sequence).
G.f.: g(x) = (x(1-2x)/(1-x) + px^2*f'(x^((2p-1)/(p-1))) + ((2p-1)/p^2)*(f'(x^(1/(p-1))) - px - 1)/(1-x) where f(x) = Sum_{k>=0} x^(p^k) and f'(z) = derivative of f(x) at x = z.
a(n) = ((3p-1)*p^(r/2) - p - 1)/(p-1) - n if both r and s are even, else a(n) = ((p^2 + 2p - 1)*p^((s-1)/2) - p - 1)/(p-1) - n, where r = ceiling(2*log_p(((p-1)n + p)/(2p-1))) and s = ceiling(2*log_p(((p-1)n + p)/p) - 1).
a(n) = (p^floor(1 + (k+1)/2) + (2p-1)*p^floor(k/2) - p - 1)/(p-1) - n, where k=r if r is odd, else k=s (with respect to r and s above; formally, k = ((r+s) - (r-s)*(-1)^r)/2).
A020703 Take the sequence of natural numbers (A000027) and reverse successive subsequences of lengths 1,3,5,7,...
1, 4, 3, 2, 9, 8, 7, 6, 5, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, 22, 21, 20, 19, 18, 17, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 81, 80, 79, 78, 77
Offset: 1
Keywords
Comments
Arrange A000027, the natural numbers, into a (square) spiral, say clockwise as shown in A068225. Read the numbers from the resulting counterclockwise spiral of the same shape that also begins with 1 and this sequence results. - Rick L. Shepherd, Aug 04 2006
Contribution from Hieronymus Fischer, Apr 30 2012: (Start)
The sequence may also be defined as follows: a(1)=1, a(n)=m^2 (where m^2 is the least square > a(k) for 1<=k
A reordering of the natural numbers.
The sequence is self-inverse in that a(a(n))=n.
(End)
Examples
a(2)=4=2^2, since 2^2 is the least square >2=a(1) and the minimal number not yet in the sequence is 2>1=a(1); a(8)=6=a(7)-1, since the minimal number not yet in the sequence (=5) is <=7=a(7).
References
- R. Honsberger, "Ingenuity in Mathematics", Table 10.4 on page 87.
- Suggested by correspondence with Michael Somos.
Links
Crossrefs
Programs
-
Mathematica
Flatten[Table[Range[n^2,(n-1)^2+1,-1],{n,10}]] (* Harvey P. Dale, Jan 10 2016 *) With[{nn=20},Flatten[Reverse/@TakeList[Range[nn^2],Range[1,nn,2]]]] (* Requires Mathematica version 11 or later *) (* Harvey P. Dale, Jan 28 2019 *)
-
PARI
a(n)=local(t); if(n<1,0,t=sqrtint(n-1); 2*(t^2+t+1)-n)
Formula
Contribution 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=k(k+1)+1, k>=0.
a(n+1)=(sqrt(a(n)-1)+2)^2, if a(n)-1 is a square, a(n+1)=a(n)-1, else.
a(n)=2*(floor(sqrt(n-1))+1)*floor(sqrt(n-1))-n+2. (End)
A132665 a(1)=1, a(2)=3, a(n) = a(n-1) + n if the minimal positive integer not yet in the sequencer is greater than a(n-1), else a(n) = a(n-1)-1.
1, 3, 2, 6, 5, 4, 11, 10, 9, 8, 7, 19, 18, 17, 16, 15, 14, 13, 12, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69
Offset: 1
Keywords
Comments
Also: a(1)=1, a(2)=3, a(n) = maximal positive number < a(n-1) not yet in the sequence, if it exists, else a(n) = a(n-1) + n.
Also: a(1)=1, a(2)=3, a(n) = a(n-1) - 1, if a(n-1) - 1 > 0 and has not been encountered so far, else a(n) = a(n-1) + n.
A permutation of the positive integers. The sequence is self-inverse, in that a(a(n)) = n.
Crossrefs
Formula
G.f.: g(x) = (F'(x) - x^2 - 1/(1-x))/(1-x) where F(x) = Sum_{k>=0} x^Fibonacci(k). F(x) is the g.f. of the Fibonacci indicator sequence (see A104162) and F'(x) = derivative of F(x).
a(n) = A000032(floor(log_phi(sqrt(5)*(n+1) + 1) + 2)) - n - 3, where phi = (1 + sqrt(5))/2 is the golden ratio.
a(n) = A000032(floor(log_phi(sqrt(5)*n + 2*phi) + 2)) - n - 3.
A182194 a(1)=2, a(n)=a(n-1)^2 if the minimal natural number > 1 not yet in the sequence is greater than a(n-1), else a(n)=a(n-1)-1.
2, 4, 3, 9, 8, 7, 6, 5, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54
Offset: 1
Keywords
Comments
A reordering of the natural numbers > 1.
The sequence is quasi self-inverse in that a(a(n-1)-1)=n.
Examples
a(2)=4=a(1)^2, since 3>2=a(1) is the minimal number not yet in the sequence (because of a(1)=2); a(15)=19=a(14)-1, since the minimal number not yet in the sequence (=10) is <=a(14)=20. a(10^4)=b(8)+b(7)-10^4-2=877. a(10^6)=b(10)+b(9)-10^6-2= 103539133.
Links
- Hieronymus Fischer, Table of n, a(n) for n = 1..10200
Formula
a(n)=a(n-1)-1, if a(n-1)-1 > 1 is not in the set {a(k)| 1<=k<=n-1}, else a(n)=a(n-1)^2.
a(a(n)-1)=n+1.
If we define b(1)=2, b(2)=3, b(k)=b(k-2)^2+1, we get the sequence 2, 3, 5, 10, 26, 101, 677, 10202, 458330, 104080805, …. The b(k) are those terms a(n) of the original sequence for which a(n+1)=a(n)^2.
With these b(k) we obtain for k>1:
a(b(k)-2)=b(k-1),
a(b(k)-1)=b(k-1)^2.
a(b(k))=b(k-1)^2 - 1.
a(n)=b(m)+b(m-1)-n-2, where m is the least index such that b(m)>n+1 (valid for n>=1).
A210882
a(1)=1, a(n)=a(n-1)-1 if a(n-1)-1 > 0 is not in the set {a(k)| 1<=k
1, 2, 3, 5, 4, 7, 6, 11, 10, 9, 8, 13, 12, 17, 16, 15, 14, 19, 18, 23, 22, 21, 20, 29, 28, 27, 26, 25, 24, 31, 30, 37, 36, 35, 34, 33, 32, 41, 40, 39, 38, 43, 42, 47, 46, 45, 44, 53, 52, 51, 50, 49, 48, 59, 58, 57, 56, 55, 54, 61, 60, 67, 66, 65, 64, 63, 62, 71
Offset: 1
Keywords
Comments
A reordering of the natural numbers.
The sequence is self-inverse in that a(a(n))=n.
If n is a prime, then a(n+1) is the next prime > n. Hence, the subsequence 2, a(2+1), a(a(2+1)+1), a(a(a(2+1)+1)+1), a(a(a(a(2+1)+1)+1)+1), ... generates the sequence of primes A000040.
Examples
a(4)=5, since 5 is the least prime > a(1), a(2), a(3), and the minimal number not yet in the sequence (=4) is greater than 3=a(3). a(5)=4, since 4 is not in the set {1,2,3,5}={a(k)| 1<=k<n}. 7=p(4)=a(p(3)+1)=a(a(p(2)+1)+1)= a(a(a(p(1)+1)+1)+1)= a(a(a(2+1)+1)+1).
Links
- Hieronymus Fischer, Table of n, a(n) for n = 1..10000
Formula
a(1)=1, a(n)=p (where p is the least prime number > a(k) for 1<=k
a(n)<>n for all n>3.
p(n+1)=a(p(n)+1), where p(n) is the n-th prime.
a(n+1)=p(m+2), if a(n)-1 is the m-th prime, else a(n+1)=a(n)-1, for n>2.
a(n)=p(m)+p(m-1)-n+1, where m is the least index such that p(m)>n-1 (valid for n>2).
Comments