OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers. It also is its own inverse (i.e. a(a(n)) = n).
From Carl R. White, Aug 23 2010: (Start)
Powers of two with even exponent exchange places with the next lowest power of two with odd exponent and vice versa, i.e., 4 swaps with 2, 256 with 128, etc.
For other numbers where n > 1, the even component (the power of two in n's prime factorization) is exchanged the opposite way: A power of two with _odd_ component is exchanged for the next lowest (even exponent) power of two and vice versa. (End)
FORMULA
From Carl R. White, Aug 23 2010: (Start)
a(1) = 1;
a(2^m) = 2^(m-(-1)^m), m > 0;
a(k*2^m) = k*2^(m+(-1)^m), m > 0, odd k > 1. (End)
EXAMPLE
a(6) = 2^1*3 -> 2^0*3 = 3; a(12) = 2^2*3 -> 2^3*3 = 24; a(25)=2^0*25 -> 2^1*25 = 50; a(1024) = 2^10 -> 2^9 = 512; a(5120) = 2^10*5 -> 2^11*5 = 10240. - Carl R. White, Aug 23 2010
MATHEMATICA
f[s_] := Block[{n = Length@s}, Append[s, If[ MemberQ[s, n], n/2, 2n]]]; Drop[ Nest[f, {1}, 70], {2}] (* Robert G. Wilson v, May 16 2006 *)
PROG
(bc) /* GNU bc */ scale=0; 1; for(n=2; n<=100; n++){m=0; for(k=n; !k%2; m++)k/=2; if(k==1){2^(m-(-1)^m)}else{k*2^(m+(-1)^m)}} /* Carl R. White, Aug 23 2010 */
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, May 07 2006
EXTENSIONS
More terms from Robert G. Wilson v, May 16 2006
STATUS
approved