%I #23 Jul 13 2013 12:03:12
%S 1,2,4,3,5,7,9,6,8,10,11,13,15,17,19,12,14,16,18,20,22,24,21,23,25,27,
%T 29,31,33,35,37,26,28,30,32,34,36,39,41,43,45,47,49,51,53,38,40,42,44,
%U 46,48,50,52,54,56,55,57,59,61,63,65,67,69,71,73,75,58,60,62,64,66,68,70
%N Variation on Golomb's sequence starting with (1,2): a(n)=length of n-th run of consecutive integers with same parity.
%C A permutation of positive integers.
%H Reinhard Zumkeller, <a href="/A093506/b093506.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F Does a(n)=n+o(n)? Does a(n)=n for infinitely many values of n?
%e Runs of odd or even terms are : (1),(2,4),(3,5,7,9),(6,8,10),(11,13,15,17,19),...and computing the number of integers in each run we get : 1,2,4,3,5,...the sequence itself.
%o (GNU bc)
%o maxarray=2^16;
%o print oe[1]=a[1]=1, ", ", a[2]=2, ", ", oe[k=0]=a[p=n=3]=4, ", ";
%o for(max=100; p<maxarray&&n<max; p++) {
%o for(i=0*k=!k; i<a[p]&&n<max; i++) {
%o an=oe[k]+=2;
%o if (++n<maxarray) a[n]=an;
%o print an, ", "
%o };
%o }; /* _Carl R. White_, Jan 05 2013 */
%o (Haskell)
%o a093506 n = a093506_list !! (n-1)
%o a093506_list = 1 : 2 : f 1 [1] [3,5..] [4,6..]
%o where f 0 (z:zs) odds evens = orun ++ f 1 (zs ++ orun) odds' evens
%o where (orun, odds') = splitAt z odds
%o f 1 (z:zs) odds evens = erun ++ f 0 (zs ++ erun) odds evens'
%o where (erun, evens') = splitAt z evens
%o -- _Reinhard Zumkeller_, Jan 06 2013
%Y Cf. A001462.
%Y Cf. A187790 (inverse), A187792 (fixed points).
%K nonn
%O 1,2
%A _Benoit Cloitre_, May 14 2004
%E Sequence corrected by _Carl R. White_, Jan 06 2013