A006519 Highest power of 2 dividing n.
1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 32, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 64, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, 32, 1, 2, 1, 4, 1, 2
Offset: 1
Examples
2^3 divides 24, but 2^4 does not divide 24, so a(24) = 8. 2^0 divides 25, but 2^1 does not divide 25, so a(25) = 1. 2^1 divides 26, but 2^2 does not divide 26, so a(26) = 2. Per _Marc LeBrun_'s 2000 comment, a(n) can also be determined with bitwise operations in two's complement. For example, given n = 48, we see that n in binary in an 8-bit byte is 00110000 while -n is 11010000. Then 00110000 AND 11010000 = 00010000, which is 16 in decimal, and therefore a(48) = 16. G.f. = x + 2*x^2 + x^3 + 4*x^4 + x^5 + 2*x^6 + x^7 + 8*x^8 + x^9 + ...
References
- Kurt Mahler, p-adic numbers and their functions, second ed., Cambridge University Press, 1981.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- T. D. Noe, Table of n, a(n) for n = 1..10000
- Dzmitry Badziahin and Jeffrey Shallit, An Unusual Continued Fraction, arXiv:1505.00667 [math.NT], 2015.
- Dzmitry Badziahin and Jeffrey Shallit, An unusual continued fraction, Proc. Amer. Math. Soc. 144 (2016), 1887-1896.
- Tyler Ball, Tom Edgar, and Daniel Juda, Dominance Orders, Generalized Binomial Coefficients, and Kummer's Theorem, Mathematics Magazine, Vol. 87, No. 2, April 2014, pp. 135-143.
- M. Beeler, R. W. Gosper and R. Schroeppel, Item 175, in Beeler, M., Gosper, R. W. and Schroeppel, R. HAKMEM. MIT AI Memo 239, Feb 29 1972.
- Ron Brown and Jonathan L. Merzel, The number of Ducci sequences with a given period, Fib. Quart., 45 (2007), 115-121.
- Daniel Bruns, Wojciech Mostowski, and Mattias Ulbrich, Implementation-level verification of algorithms with KeY, International Journal on Software Tools for Technology Transfer, November 2013.
- Victor Meally, Letter to N. J. A. Sloane, May 1975.
- Laurent Orseau, Levi H. S. Lelis, and Tor Lattimore, Zooming Cautiously: Linear-Memory Heuristic Search With Node Expansion Guarantees, arXiv:1906.03242 [cs.AI], 2019.
- Laurent Orseau, Levi H. S. Lelis, Tor Lattimore, and Théophane Weber, Single-Agent Policy Tree Search With Guarantees, arXiv:1811.10928 [cs.AI], 2018, also in Advances in Neural Information Processing Systems, 32nd Conference on Neural Information Processing Systems (NIPS 2018), Montréal, Canada.
- Ralf Stephan, Some divide-and-conquer sequences with (relatively) simple ordinary generating functions.
- Ralf Stephan, Table of generating functions.
- Ralf Stephan, Divide-and-conquer generating functions. I. Elementary sequences, arXiv:math/0307027 [math.CO], 2003.
- Eric Weisstein's World of Mathematics, Even Part.
- Wikipedia, Converse nonimplication.
- Index entries for sequences related to binary expansion of n.
Crossrefs
Programs
-
Haskell
import Data.Bits ((.&.)) a006519 n = n .&. (-n) :: Integer -- Reinhard Zumkeller, Mar 11 2012, Dec 29 2011
-
Julia
using IntegerSequences [EvenPart(n) for n in 1:102] |> println # Peter Luschny, Sep 25 2021
-
Magma
[2^Valuation(n, 2): n in [1..100]]; // Vincenzo Librandi, Mar 27 2015
-
Maple
with(numtheory): for n from 1 to 200 do if n mod 2 = 1 then printf(`%d,`,1) else printf(`%d,`,2^ifactors(n)[2][1][2]) fi; od: A006519 := proc(n) if type(n,'odd') then 1 ; else for f in ifactors(n)[2] do if op(1,f) = 2 then return 2^op(2,f) ; end if; end do: end if; end proc: # R. J. Mathar, Oct 25 2010 A006519 := n -> 2^padic[ordp](n,2): # Peter Luschny, Nov 26 2010
-
Mathematica
lowestOneBit[n_] := Block[{k = 0}, While[Mod[n, 2^k] == 0, k++]; 2^(k - 1)]; Table[lowestOneBit[n], {n, 102}] (* Robert G. Wilson v Nov 17 2004 *) Table[2^IntegerExponent[n, 2], {n, 128}] (* Jean-François Alcover, Feb 10 2012 *) Table[BitAnd[BitNot[i - 1], i], {i, 1, 102}] (* Peter Luschny, Oct 10 2019 *)
-
PARI
{a(n) = 2^valuation(n, 2)};
-
PARI
a(n)=1<
Joerg Arndt, Jun 10 2011 -
PARI
a(n)=bitand(n,-n); \\ Joerg Arndt, Jun 10 2011
-
PARI
a(n)=direuler(p=2,n,if(p==2,1/(1-2*X),1/(1-X)))[n] \\ Ralf Stephan, Mar 27 2015
-
Python
def A006519(n): return n&-n # Chai Wah Wu, Jul 06 2022
-
Scala
(1 to 128).map(Integer.lowestOneBit()) // _Alonso del Arte, Mar 04 2020
Formula
a(n) = n AND -n (where "AND" is bitwise, and negative numbers are represented in two's complement in a suitable bit width). - Marc LeBrun, Sep 25 2000, clarified by Alonso del Arte, Mar 16 2020
Also: a(n) = gcd(2^n, n). - Labos Elemer, Apr 22 2003
Multiplicative with a(p^e) = p^e if p = 2; 1 if p > 2. - David W. Wilson, Aug 01 2001
G.f.: Sum_{k>=0} 2^k*x^2^k/(1 - x^2^(k+1)). - Ralf Stephan, May 06 2003
Dirichlet g.f.: zeta(s)*(2^s - 1)/(2^s - 2) = zeta(s)*(1 - 2^(-s))/(1 - 2*2^(-s)). - Ralf Stephan, Jun 17 2007
a(n) = 2^A007814(n). - R. J. Mathar, Oct 25 2010
a((2*k - 1)*2^e) = 2^e, k >= 1, e >= 0. - Johannes W. Meijer, Jun 07 2011
a(n) = denominator of Euler(n-1, 1). - Arkadiusz Wesolowski, Jul 12 2012
a(n) = (n XOR floor(n/2)) XOR (n-1 XOR floor((n-1)/2)) = n - (n AND n-1) (where "AND" is bitwise). - Gary Detlefs, Jun 12 2014
a(n) = ((n XOR n-1)+1)/2. - Gary Detlefs, Jul 02 2014
a(n) = A171977(n)/2. - Peter Kern, Jan 04 2017
a(n) = (n-1) o n where 'o' is the bitwise converse nonimplication. 'o' is not commutative. n o (n+1) = A135481(n). - Peter Luschny, Oct 10 2019
From Peter Munn, Dec 13 2019: (Start)
Sum_{k=1..n} a(k) ~ (1/(2*log(2)))*n*log(n) + (3/4 + (gamma-1)/(2*log(2)))*n, where gamma is Euler's constant (A001620). - Amiram Eldar, Nov 15 2022
a(n) = n / A000265(n). - Amiram Eldar, May 22 2025
Extensions
More terms from James Sellers, Jun 20 2000
Comments