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
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, May 07 2006
EXTENSIONS
More terms from Robert G. Wilson v, May 16 2006
STATUS
approved