login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A118966 a(n) = (n+1)/2 if n occurs among the first n-1 terms of the sequence, otherwise a(n) = 2*n - 1. 2
1, 3, 2, 7, 9, 11, 4, 15, 5, 19, 6, 23, 25, 27, 8, 31, 33, 35, 10, 39, 41, 43, 12, 47, 13, 51, 14, 55, 57, 59, 16, 63, 17, 67, 18, 71, 73, 75, 20, 79, 21, 83, 22, 87, 89, 91, 24, 95, 97, 99, 26, 103, 105, 107, 28, 111, 29, 115, 30, 119, 121, 123, 32, 127, 129, 131, 34, 135 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers. It is also its own inverse (i.e., a(a(n)) = n).
From Thomas Scheuerle, Dec 24 2020: (Start)
The same sequence can be generated by defining a(0)=0 and a(1)=1 and, for each n>1, choosing the smallest unused positive integer such that max(a(n)/n) will increase or min(a(n)/n) will decrease.
Proof: Three conditions are required to guarantee that the definitions are equivalent. The first condition is that this is a permutation; this is satisfied because this is a permutation involution. This is because (n+1)/2 is the inverse function of 2n-1, which is applied only if n is not already used in the sequence. The second condition is that, with each new term, max(a(n)/n) increases or min(a(n)/n) decreases. This is obviously the case because the next term would be either 2n-1, with would increase max(a(n)/n), or (n+1)/2, which would decrease min(a(n)/n). The third and last condition is that each new term is the smallest possible number satisfying the first two conditions. This holds because 2n-1 is the smallest possible number m*n+b where the slope m is > 1 and a(1) = 1. (A slope > 1 is needed for condition 2.)
(End)
LINKS
FORMULA
a(n) = A073675(n-1) + 1. - Thomas Scheuerle, Dec 27 2020
MATHEMATICA
f[s_] := Block[{n = Length@s}, Append[s, If[MemberQ[s, n], (n + 1)/2, 2n - 1]]]; Rest@Nest[f, {1}, 70] (* Robert G. Wilson v, May 16 2006 *)
(* Program to test alternative definition : *)
(* "Permutation of natural number such that max(a(n)/n)-min(a(n)/n) increases monotonously by using smallest possible next number, a(0) = 0, a(1) = 1." *)
Block[{a = {0, 1}, b = {1}, c = {0}, k, r, s}, Do[k = 2; While[Nand[Set[s, Max[#] - Min[#]] > c[[-1]], FreeQ[a, k]] &@ Append[b, Set[r, k/i]], k++]; AppendTo[a, k]; AppendTo[b, r]; AppendTo[c, s], {i, 2, 55}]; a] (* Michael De Vlieger, Dec 11 2020 *)
PROG
(MATLAB)
% Program to test alternative definition:
%"Permutation of natural number such that max(a(n)/n)-min(a(n)/n) increases monotonously by using smallest possible next number, a(0) = 0, a(1) = 1."
function a = A118966( max_n )
a(1) = 0;
a(2) = 1;
m_max = 1;
m_min = 1;
n = 3;
t = 1;
while n <= max_n
% search next number t not yet used in a
while ~isempty(find(a==t, 1))
t = t+1;
end
m = t/(n-1);
% check slope m
if m < m_min || m > m_max
% we found a candidate
a(n) = t;
n = n+1;
if m > m_max
m_max = m;
end
if m < m_min
m_min = m;
end
t = 1;
else
% number t does not yet fit
t = t+1;
end
end
end
% Thomas Scheuerle, Dec 24 2020
CROSSREFS
Sequence in context: A026210 A367822 A257326 * A351904 A351903 A359973
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, May 07 2006
EXTENSIONS
More terms from Robert G. Wilson v, May 16 2006
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:06 EDT 2024. Contains 371964 sequences. (Running on oeis4.)