OFFSET
1,1
COMMENTS
The parity of the sequence is E,D,E,E,E,D,E,E,E,D,E,E,E,D,E,E,E,D,E,E,E,D,..., that is, an D followed by three E's from the second term onwards.
Closely related to A035263: if A035263(n) = 1, a(n) = 2n; otherwise a(n)=n/2. - Franklin T. Adams-Watters, Feb 02 2006
This permutation is self-inverse. This is the case r=2 of sequences where a(n)=floor(n/r) if floor(n/r)>0 and not already in the sequence, a(n) = floor(n*r) otherwise. All such sequences (for r>=1) are permutations of the natural numbers. - Franklin T. Adams-Watters, Feb 06 2006
LINKS
FORMULA
If valuation(n,2) is even, a(n) = 2n; otherwise a(n)=n/2, where valuation(n,2) = A007814(n) is the exponent of the highest power of 2 dividing n. - Franklin T. Adams-Watters, Feb 06 2006, Jul 31 2009
a(k*2^m) = k*2^(m+(-1)^m), m >= 0, odd k >= 1. - Carl R. White, Aug 23 2010
MAPLE
a:= proc(n) local i, m; m:=n;
for i from 0 while irem(m, 2, 'r')=0 do m:=r od;
m*2^`if`(irem(i, 2)=1, i-1, i+1)
end:
seq(a(n), n=1..80); # Alois P. Heinz, Feb 10 2014
MATHEMATICA
a[n_] := Module[{i, m = n}, For[i = 0, {q, r} = QuotientRemainder[m, 2]; r == 0, i++, m = q]; m*2^If[Mod[i, 2] == 1, i-1, i+1]]; Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Jun 10 2015, after Alois P. Heinz *)
PROG
(GNU bc) scale=0; for(n=1; n<=100; n++){m=0; for(k=n; !k%2; m++)k/=2; k*2^(m+(-1)^m)} /* Carl R. White, Aug 23 2010 */
(PARI) a(n) = if (valuation(n, 2) % 2, n/2, 2*n); \\ Michel Marcus, Mar 17 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Aug 11 2002
EXTENSIONS
More terms and comment from Franklin T. Adams-Watters, Feb 06 2006, Jul 31 2009
More terms from Franklin T. Adams-Watters, Feb 06 2006
Edited by N. J. A. Sloane, Jul 31 2009
Typo fixed by Charles R Greathouse IV, Apr 29 2010
STATUS
approved