OFFSET
1,2
COMMENTS
For n>1, let d be the number of bits in n, and n' = n/gcd(n,2^d) = n/2^valuation(n,2) = A000265(n). Then a(n) = (2^{n-2}+mod(-(2^{n-2}),n')) * 2^d + n. (The mod function used here always returns a nonnegative result; e.g. mod(-2,7) = 5.) The alternative to use n/p^valuation(n,p) instead of gcd(n,p^d) works in any prime base p.
The word "after" in the definition can be interpreted as either "immediately after" or "at some point after" - the resulting sequence is the same.
EXAMPLE
a(4) = 36 = 100100_2; 100, the binary representation of 4, occurs after 4-1 = 3 bits.
PROG
(PARI) numbit(n)=my(r=1); while(n>=2, n\=2; r++); r a(n) = my(k, m); if(n<=1, n, k=2^numbit(n); m=2^(n-2); (-m%(n\gcd(n, k))+m)*k+n) \\ Could use 2^valuation(n, 2) instead of gcd(n, k).
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Franklin T. Adams-Watters, Jul 25 2014
STATUS
approved
