%I #26 Mar 07 2020 06:19:28
%S 1,2,3,1,4,5,1,2,6,1,7,3,1,2,8,1,9,4,1,2,10,1,3,11,1,2,5,1,12,13,1,2,
%T 3,1,4,6,1,2,14,1,15,3,1,2,7,1,5,4,1,2,16,1,3,17,1,2,8,1,18,6,1,2,3,1,
%U 4,19,1,2,5,1,9,3,1,2,20,1,21,4,1,2,7,1,3,10,1,2,22,1,5,6,1,2,3,1,4,23,1
%N First terms in the rearrangements of integer numbers (see comments).
%C Take the sequence of natural numbers:
%C s0=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
%C Move the first term s(1)=1 to 2*1 places to the right:
%C s1=2,3,1,4,5,6,7,8,9,10,11,12,13,14,15,16,
%C Move the first term s(1)=2 to 2*2 places to the right:
%C s2=3,1,4,5,2,6,7,8,9,10,11,12,13,14,15,16,
%C Repeating the procedure we get successively:
%C s3=1,4,5,2,6,7,3,8,9,10,11,12,13,14,15,16,
%C s4=4,5,1,2,6,7,3,8,9,10,11,12,13,14,15,16,
%C s5=5,1,2,6,7,3,8,9,4,10,11,12,13,14,15,16,
%C s6=1,2,6,7,3,8,9,4,10,11,5,12,13,14,15,16,
%C .......................................................................
%C s100=8,3,1,2,24,25,4,5,12,7,6,26,9,27,13,28,29,10,14,30,31,15,11,
%C 32,33,16,34,35,17,36,37,18,38,39,19,40,41,20,42,43,21,44,45,22,
%C 46,47,23,48,49,50,51,52,53,54,55,56,57,58,59,60,
%C The sequence A104706 gives the first terms in the rearrangements s0,s1,s2,...,s100. Cf. A104705
%H Robert Israel, <a href="/A104706/b104706.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = A028920(2n-1)-1. - _Benoit Cloitre_, Mar 09 2007
%p A104706:= proc(N) # to produce a(1) .. a(N)
%p local A, R, n,M;
%p M:= N;
%p R:= $1..M;
%p A[1]:= 1;
%p for n from 2 to N do
%p if 2*R[1]+1 > M then
%p R:= R, [$M+1..M+N]
%p fi;
%p R:= R[2..2*R[1]+1],R[1],R[2*R[1]+2..N];
%p A[n]:= R[1];
%p od:
%p seq(A[n], n=1..N);
%p end proc:
%p A104706(100); # _Robert Israel_, Dec 04 2015
%t s=Range[100];bb={1};Do[s=Drop[Insert[s, s[[1]], 2+2s[[1]]], 1];bb=Append[bb, s[[1]]], {i, 100}];bb
%t NestList[Rest[Insert[#, #[[1]], 2 + 2 #[[1]]]] &, Range[30], 30][[All, 1]] (* _Birkas Gyorgy_, Mar 03 2011 *)
%o (Sage)
%o def A104706(n):
%o m, N = 2, 2*n-1
%o while true:
%o if m.divides(N): return m-2
%o N = N*(m-1)//m
%o m += 1
%o print([A104706(n) for n in (1..97)]) # _Peter Luschny_, Dec 04 2015
%Y Cf. A104705, A028920.
%K easy,nonn
%O 1,2
%A _Zak Seidov_, Mar 19 2005