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

%I #40 Mar 07 2021 00:58:24

%S 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,

%T 14,55,57,59,16,63,17,67,18,71,73,75,20,79,21,83,22,87,89,91,24,95,97,

%U 99,26,103,105,107,28,111,29,115,30,119,121,123,32,127,129,131,34,135

%N a(n) = (n+1)/2 if n occurs among the first n-1 terms of the sequence, otherwise a(n) = 2*n - 1.

%C Sequence is a permutation of the positive integers. It is also its own inverse (i.e., a(a(n)) = n).

%C From _Thomas Scheuerle_, Dec 24 2020: (Start)

%C 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.

%C 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.)

%C (End)

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(n) = A073675(n-1) + 1. - _Thomas Scheuerle_, Dec 27 2020

%t 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 *)

%t (* Program to test alternative definition : *)

%t (* "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." *)

%t 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 *)

%o (MATLAB)

%o % Program to test alternative definition:

%o %"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."

%o function a = A118966( max_n )

%o a(1) = 0;

%o a(2) = 1;

%o m_max = 1;

%o m_min = 1;

%o n = 3;

%o t = 1;

%o while n <= max_n

%o % search next number t not yet used in a

%o while ~isempty(find(a==t, 1))

%o t = t+1;

%o end

%o m = t/(n-1);

%o % check slope m

%o if m < m_min || m > m_max

%o % we found a candidate

%o a(n) = t;

%o n = n+1;

%o if m > m_max

%o m_max = m;

%o end

%o if m < m_min

%o m_min = m;

%o end

%o t = 1;

%o else

%o % number t does not yet fit

%o t = t+1;

%o end

%o end

%o end

%o % _Thomas Scheuerle_, Dec 24 2020

%Y Cf. A118967, A073675.

%K easy,nonn

%O 1,2

%A _Leroy Quet_, May 07 2006

%E More terms from _Robert G. Wilson v_, May 16 2006

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 23 15:17 EDT 2024. Contains 371916 sequences. (Running on oeis4.)