A171977 a(n) = 2^(k+1) where 2^k is the highest power of 2 dividing n.
2, 4, 2, 8, 2, 4, 2, 16, 2, 4, 2, 8, 2, 4, 2, 32, 2, 4, 2, 8, 2, 4, 2, 16, 2, 4, 2, 8, 2, 4, 2, 64, 2, 4, 2, 8, 2, 4, 2, 16, 2, 4, 2, 8, 2, 4, 2, 32, 2, 4, 2, 8, 2, 4, 2, 16, 2, 4, 2, 8, 2, 4, 2
Offset: 1
Links
- Antti Karttunen, Table of n, a(n) for n = 1..16383
- Sandor Csörgö and Gordon Simons, On Steinhaus' resolution of the St. Petersburg paradox, Probab. Math. Statist. 14 (1993), 157--172. MR1321758 (96b:60017). - _Peter Kern_, Aug 28 2015
- Roger B. Eggleton, Aviezri S. Fraenkel, and R. Jamie Simpson, Beatty sequences and Langford sequences, Graph theory and combinatorics (Marseille-Luminy, 1990). Discrete Math. 111 (1993), no. 1-3, 165--178. MR1210094 (94a:11018). See Example 2.6. - _N. J. A. Sloane_, Mar 18 2012
- Hugo Steinhaus, The so-called Petersburg paradox, Colloq. Math. 2 (1949), 56--58. MR0039937 (12,619e).
Programs
-
Maple
a := proc(n) local k: k:=1: while frac(n/2^k) = 0 do k := k+1 end do: k := k-1: a(n) := 2^(k+1) end: seq(a(n), n=1..63); # Johannes W. Meijer, Nov 04 2012 seq(2^(1 + padic[ordp](n, 2)), n = 1..63); # Peter Luschny, Nov 27 2020
-
Mathematica
Table[-BitXor[-i,i], {i, 200}] (* Peter Luschny, Jun 01 2011 *) a[n_] := 2^(IntegerExponent[n, 2] + 1); Array[a, 100] (* Jean-François Alcover, May 09 2017 *)
-
PARI
A171977(n) = 2^(1+valuation(n,2)); \\ Antti Karttunen, Nov 06 2018
-
Python
def A171977(n): return (n&-n)<<1 # Chai Wah Wu, Jul 13 2022
Formula
a(n) = -(-n XOR n). XOR the bitwise operation on the two's complement representation for negative integers. - Peter Luschny, Jun 01 2011
a(n) = A038712(n)+1. - Franz Vrabec, Mar 03 2012
a(n) = 2^A001511(n). - Franz Vrabec, Oct 22 2012
a(n) = 2*A006519(n). - Antti Karttunen, Nov 06 2018
Extensions
I edited this sequence, based on an email message from the author. - N. J. A. Sloane, Nov 20 2010
Definition simplified by N. J. A. Sloane, Mar 18 2012
Comments