CINXE.COM
A001969 - OEIS
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <link rel="stylesheet" href="/styles.css"> <meta name="format-detection" content="telephone=no"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name=viewport content="width=device-width, initial-scale=1"> <meta name="keywords" content="OEIS,integer sequences,Sloane" /> <title>A001969 - OEIS</title> <link rel="search" type="application/opensearchdescription+xml" title="OEIS" href="/oeis.xml"> <script> var myURL = "\/A001969" function redir() { var host = document.location.hostname; if(host != "oeis.org" && host != "127.0.0.1" && !/^([0-9.]+)$/.test(host) && host != "localhost" && host != "localhost.localdomain") { document.location = "https"+":"+"//"+"oeis"+".org/" + myURL; } } function sf() { if(document.location.pathname == "/" && document.f) document.f.q.focus(); } </script> </head> <body bgcolor=#ffffff onload="redir();sf()"> <div class=loginbar> <div class=login> <a href="/login?redirect=%2fA001969">login</a> </div> </div> <div class=center><div class=top> <center> <div class=donors> The OEIS is supported by <a href="http://oeisf.org/#DONATE">the many generous donors to the OEIS Foundation</a>. </div> <div class=banner> <a href="/"><img class=banner border="0" width="600" src="/banner2021.jpg" alt="A001969 - OEIS"></a> </div> </center> </div></div> <div class=center><div class=pagebody> <div class=searchbarcenter> <form name=f action="/search" method="GET"> <div class=searchbargreet> <div class=searchbar> <div class=searchq> <input class=searchbox maxLength=1024 name=q value="" title="Search Query"> </div> <div class=searchsubmit> <input type=submit value="Search" name=go> </div> <div class=hints> <span class=hints><a href="/hints.html">Hints</a></span> </div> </div> <div class=searchgreet> (Greetings from <a href="/welcome">The On-Line Encyclopedia of Integer Sequences</a>!) </div> </div> </form> </div> <div class=sequence> <div class=space1></div> <div class=line></div> <div class=seqhead> <div class=seqnumname> <div class=seqnum> A001969 </div> <div class=seqname> Evil numbers: nonnegative integers with an even number of 1's in their binary expansion. <br><font size=-1>(Formerly M2395 N0952)</font> </div> </div> <div class=scorerefs> 301 </div> </div> <div> <div class=seqdatabox> <div class=seqdata>0, 3, 5, 6, 9, 10, 12, 15, 17, 18, 20, 23, 24, 27, 29, 30, 33, 34, 36, 39, 40, 43, 45, 46, 48, 51, 53, 54, 57, 58, 60, 63, 65, 66, 68, 71, 72, 75, 77, 78, 80, 83, 85, 86, 89, 90, 92, 95, 96, 99, 101, 102, 105, 106, 108, 111, 113, 114, 116, 119, 120, 123, 125, 126, 129</div> <div class=seqdatalinks> (<a href="/A001969/list">list</a>; <a href="/A001969/graph">graph</a>; <a href="/search?q=A001969+-id:A001969">refs</a>; <a href="/A001969/listen">listen</a>; <a href="/history?seq=A001969">history</a>; <a href="/search?q=id:A001969&fmt=text">text</a>; <a href="/A001969/internal">internal format</a>) </div> </div> </div> <div class=entry> <div class=section> <div class=sectname>OFFSET</div> <div class=sectbody> <div class=sectline>1,2</div> </div> </div> <div class=section> <div class=sectname>COMMENTS</div> <div class=sectbody> <div class=sectline>This sequence and <a href="/A000069" title="Odious numbers: numbers with an odd number of 1's in their binary expansion.">A000069</a> give the unique solution to the problem of splitting the nonnegative integers into two classes in such a way that sums of pairs of distinct elements from either class occur with the same multiplicities [Lambek and Moser]. Cf. <a href="/A000028" title="Let k = p_1^e_1 p_2^e_2 p_3^e_3 ... be the prime factorization of n. Sequence gives k such that the sum of the numbers of 1'...">A000028</a>, <a href="/A000379" title="Numbers where total number of 1-bits in the exponents of their prime factorization is even; a 2-way classification of intege...">A000379</a>.</div> <div class=sectline>In French: les nombres pa茂ens.</div> <div class=sectline>Theorem: First differences give <a href="/A036585" title="Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b.">A036585</a>. (Observed by <a href="/wiki/User:Franklin_T._Adams-Watters">Franklin T. Adams-Watters</a>.)</div> <div class=sectline>Proof from <a href="/wiki/User:Max_Alekseyev">Max Alekseyev</a>, Aug 30 2006 (edited by <a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a>, Jan 05 2021): (Start)</div> <div class=sectline>Observe that if the last bit of a(n) is deleted, we get the nonnegative numbers 0, 1, 2, 3, ... in order.</div> <div class=sectline>The last bit in a(n+1) is 1 iff the number of bits in n is odd, that is, iff <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(n+1) is 1.</div> <div class=sectline>So, taking into account the different offsets here and in <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>, we have a(n) = 2*(n-1) + <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(n-1).</div> <div class=sectline>Therefore the first differences of the present sequence equal 2 + first differences of <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>, which equals <a href="/A036585" title="Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b.">A036585</a>. QED (End)</div> <div class=sectline>Integers k such that <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(k-1)=0. - <a href="/wiki/User:Benoit_Cloitre">Benoit Cloitre</a>, Nov 15 2003</div> <div class=sectline>Indices of zeros in the Thue-Morse sequence <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a> shifted by 1. - <a href="/wiki/User:Tanya_Khovanova">Tanya Khovanova</a>, Feb 13 2009</div> <div class=sectline>Conjecture, checked up to 10^6: a(n) is also the sequence of numbers k representable as k = ror(x) XOR rol(x) (for some integer x) where ror(x)=<a href="/A038572" title="a(n) = n rotated one binary place to the right.">A038572</a>(x) is x rotated one binary place to the right, rol(x)=<a href="/A006257" title="Josephus problem: a(2*n) = 2*a(n)-1, a(2*n+1) = 2*a(n)+1.">A006257</a>(x) is x rotated one binary place to the left, and XOR is the binary exclusive-or operator. - <a href="/wiki/User:Alex_Ratushnyak">Alex Ratushnyak</a>, May 14 2016</div> <div class=sectline>From <a href="/wiki/User:Charlie_Neder">Charlie Neder</a>, Oct 07 2018: (Start)</div> <div class=sectline>Conjecture is true: ror(x) and rol(x) have an even number of 1 bits in total (= 2 * <a href="/A000120" title="1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).">A000120</a>(x)), and XOR preserves the parity of this total, so the resulting number must have an even number of 1 bits. An x can be constructed corresponding to a(n) like so:</div> <div class=sectline>If the number of bits in a(n) is even, add a leading 0 so a(n) is 2k+1 bits long.</div> <div class=sectline>Do an inverse shuffle on a(n), then "divide" by 11, rotate the result k bits to the right, and shuffle to get x. (End)</div> <div class=sectline>Numbers of the form m XOR (2*m) for some m >= 0. - <a href="/wiki/User:R茅my_Sigrist">R茅my Sigrist</a>, Feb 07 2021</div> <div class=sectline>The terms "evil numbers" and "odious numbers" were coined by Richard K. Guy, c. 1976 (Haque and Shallit, 2016) and appeared in the book by Berlekamp et al. (Vol. 1, 1st ed., 1982). - <a href="/wiki/User:Amiram_Eldar">Amiram Eldar</a>, Jun 08 2021</div> </div> </div> <div class=section> <div class=sectname>REFERENCES</div> <div class=sectbody> <div class=sectline>Elwyn R. Berlekamp, John H. Conway, Richard K. Guy, Winning Ways for Your Mathematical Plays, Volume 1, 2nd ed., A K Peters, 2001, chapter 14, p. 110.</div> <div class=sectline>Hugh L. Montgomery, Ten Lectures on the Interface Between Analytic Number Theory and Harmonic Analysis, Amer. Math. Soc., 1996, p. 208.</div> <div class=sectline>Donald J. Newman, A Problem Seminar, Springer; see Problem #89.</div> <div class=sectline>Vladimir S. Shevelev, On some identities connected with the partition of the positive integers with respect to the Morse sequence, Izv. Vuzov of the North-Caucasus region, Nature sciences 4 (1997), 21-23 (Russian).</div> <div class=sectline>N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).</div> <div class=sectline>N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).</div> </div> </div> <div class=section> <div class=sectname>LINKS</div> <div class=sectbody> <div class=sectline>N. J. A. Sloane, <a href="/A001969/b001969.txt">Table of n, a(n) for n = 1..10000</a></div> <div class=sectline>Jean-Paul Allouche and Henri Cohen, <a href="http://dx.doi.org/10.1112/blms/17.6.531">Dirichlet series and curious infinite products</a>, Bull. London Math. Soc., Vol. 17 (1985), pp. 531-538.</div> <div class=sectline>Jean-Paul Allouche and Jeffrey Shallit, <a href="http://www.cs.uwaterloo.ca/~shallit/Papers/as0.ps">The ring of k-regular sequences</a>, Theoretical Computer Sci., Vol. 98 (1992), pp. 163-197; <a href="https://doi.org/10.1016/0304-3975(92)90001-V">DOI</a>.</div> <div class=sectline>Jean-Paul Allouche, Benoit Cloitre, and Vladimir Shevelev, <a href="http://arxiv.org/abs/1405.6214">Beyond odious and evil</a>, arXiv preprint arXiv:1405.6214 [math.NT], 2014.</div> <div class=sectline>Jean-Paul Allouche, Benoit Cloitre, and Vladimir Shevelev, <a href="https://doi.org/10.1007/s00010-015-0345-3">Beyond odious and evil</a>, Aequationes mathematicae, Vol. 90 (2016), pp. 341-353; <a href="http://www.math.bgu.ac.il/~shevelev/58_Beyond_J.pdf">alternative link</a>.</div> <div class=sectline>Chris Bernhardt, <a href="https://www.jstor.org/stable/27643161">Evil twins alternate with odious twins</a>, Math. Mag., Vol. 82, No. 1 (2009), pp. 57-62; <a href="https://web.archive.org/web/20181126095925/http://faculty.fairfield.edu/cbernhardt/evil%20twins.pdf">alternative link</a>.</div> <div class=sectline>Joshua N. Cooper, Dennis Eichhorn and Kevin O'Bryant, <a href="https://doi.org/10.1142/S1793042106000693">Reciprocals of binary power series</a>, International Journal of Number Theory, Vol. 2, No. 4 (2006), pp. 499-522; <a href="https://arxiv.org/abs/math/0506496">arXiv preprint</a>, arXiv:math/0506496 [math.NT], 2005.</div> <div class=sectline>Aviezri S. Fraenkel, <a href="https://doi.org/10.1016/j.disc.2011.03.032">The vile, dopey, evil and odious game players</a>, Discrete Math., Vol. 312, No. 1 (2012), pp. 42-46.</div> <div class=sectline>E. Fouvry and C. Mauduit, <a href="http://dx.doi.org/10.1007/BF01444238">Sommes des chiffres et nombres presque premiers</a>, (French) [Sums of digits and almost primes] Math. Ann., Vol. 305, No. 3 (1996), pp. 571-599. MR1397437 (97k:11029)</div> <div class=sectline>Sajed Haque, Chapter 3.2 of <a href="https://uwspace.uwaterloo.ca/bitstream/handle/10012/12234/Haque_Sajed.pdf">Discriminators of Integer Sequences</a>, thesis, University of Waterloo, Ontario, Canada, 2017. See p. 38.</div> <div class=sectline>Sajed Haque and Jeffrey Shallit, <a href="http://www.kurims.kyoto-u.ac.jp/EMIS/journals/INTEGERS/papers/q76/q76.pdf">Discriminators and k-Regular Sequences</a> Integers, Vol. 16 (2016), Article A76; <a href="https://arxiv.org/abs/1605.00092">arXiv preprint</a>, arXiv:1605.00092 [cs.DM], 2016.</div> <div class=sectline>Tanya Khovanova, <a href="http://arxiv.org/abs/1410.2193">There are no coincidences</a>, arXiv preprint 1410.2193 [math.CO], 2014.</div> <div class=sectline>J. Lambek and L. Moser, <a href="http://dx.doi.org/10.4153/CMB-1959-013-x">On some two way classifications of integers</a>, Canad. Math. Bull., Vol. 2, No. 2 (1959), pp. 85-89.</div> <div class=sectline>P. Mathonet, M. Rigo, M. Stipulanti and N. Z茅na茂di, <a href="https://arxiv.org/abs/2201.06636">On digital sequences associated with Pascal's triangle</a>, arXiv:2201.06636 [math.NT], 2022.</div> <div class=sectline>M. D. McIlroy, <a href="http://dx.doi.org/10.1137/0203020">The number of 1's in binary integers: bounds and extremal properties</a>, SIAM J. Comput., Vol. 3, No. 4 (1974), pp. 255-261.</div> <div class=sectline>Jeffrey O. Shallit, <a href="http://dx.doi.org/10.1016/0022-314X(85)90045-9">On infinite products associated with sums of digits</a>, J. Number Theory, Vol. 21, No. 2 (1985), pp. 128-134.</div> <div class=sectline>Jeffrey Shallit, <a href="https://arxiv.org/abs/2103.10904">Frobenius Numbers and Automatic Sequences</a>, arXiv:2103.10904 [math.NT], 2021.</div> <div class=sectline>Jeffrey Shallit, <a href="https://arxiv.org/abs/2112.13627">Additive Number Theory via Automata and Logic</a>, arXiv:2112.13627 [math.NT], 2021.</div> <div class=sectline>Vladimir Shevelev and Peter J. C. Moses, <a href="http://arxiv.org/abs/1207.0404">Tangent power sums and their applications</a>, arXiv preprint arXiv:1207.0404 [math.NT], 2012. - From <a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a>, Dec 17 2012</div> <div class=sectline>Vladimir Shevelev and Peter J. C. Moses, <a href="http://arxiv.org/abs/1209.5705">A family of digit functions with large periods</a>, arXiv preprint arXiv:1209.5705 [math.NT], 2012.</div> <div class=sectline>Vladimir Shevelev and Peter J. C. Moses, <a href="http://www.emis.de/journals/INTEGERS/papers/o64/o64.Abstract.html">Tangent power sums and their applications</a>, INTEGERS, Vol. 14 (2014) #64.</div> <div class=sectline>Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/EvilNumber.html">Evil Number</a>.</div> <div class=sectline><a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a></div> <div class=sectline><a href="/index/Cor#core">Index entries for "core" sequences</a></div> </div> </div> <div class=section> <div class=sectname>FORMULA</div> <div class=sectbody> <div class=sectline>a(n+1) - <a href="/A001285" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 1 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A001285</a>(n) = 2n-1 has been verified for n <= 400. - <a href="/wiki/User:John_W._Layman">John W. Layman</a>, May 16 2003 [This can be directly verified by comparing <a href="/wiki/User:Ralf_Stephan">Ralf Stephan</a>'s formulas for this sequence (see below) and for <a href="/A001285" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 1 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A001285</a>. - <a href="/wiki/User:Jianing_Song">Jianing Song</a>, Nov 04 2024]</div> <div class=sectline>Note that 2n+1 is in the sequence iff 2n is not and so this sequence has asymptotic density 1/2. - <a href="/wiki/User:Franklin_T._Adams-Watters">Franklin T. Adams-Watters</a>, Aug 23 2006</div> <div class=sectline>a(n) = (1/2) * (4n - 3 - (-1)^<a href="/A000120" title="1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).">A000120</a>(n-1)). - <a href="/wiki/User:Ralf_Stephan">Ralf Stephan</a>, Sep 14 2003</div> <div class=sectline>G.f.: Sum_{k>=0} (t(3+2t+3t^2)/(1-t^2)^2) * Product_{l=0..k-1} (1-x^(2^l)), where t = x^2^k. - <a href="/wiki/User:Ralf_Stephan">Ralf Stephan</a>, Mar 25 2004</div> <div class=sectline>a(2*n+1) + a(2*n) = <a href="/A017101" title="a(n) = 8n + 3.">A017101</a>(n-1) = 8*n-5.</div> <div class=sectline>a(2*n) - a(2*n-1) gives the Thue-Morse sequence (3, 1 version): 3, 1, 1, 3, 1, 3, 3, 1, 1, 3, .... <a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>(n) + <a href="/A000069" title="Odious numbers: numbers with an odd number of 1's in their binary expansion.">A000069</a>(n) = <a href="/A016813" title="a(n) = 4*n + 1.">A016813</a>(n-1) = 4*n-3. - <a href="/wiki/User:Philippe_Del茅ham">Philippe Del茅ham</a>, Feb 04 2004</div> <div class=sectline>a(1) = 0; for n > 1: a(n) = 3*n-3 - a(n/2) if n even, a(n) = a((n+1)/2)+n-1 if n odd.</div> <div class=sectline>Let b(n) = 1 if sum of digits of n is even, -1 if it is odd; then Shallit (1985) showed that Product_{n>=0} ((2n+1)/(2n+2))^b(n) = 1/sqrt(2).</div> <div class=sectline>a(n) = 2n - 2 + <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(n-1). - <a href="/wiki/User:Franklin_T._Adams-Watters">Franklin T. Adams-Watters</a>, Aug 28 2006</div> <div class=sectline><a href="/A005590" title="a(0) = 0, a(1) = 1, a(2n) = a(n), a(2n+1) = a(n+1) - a(n).">A005590</a>(a(n-1)) <= 0. - <a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Apr 11 2012</div> <div class=sectline><a href="/A106400" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 1 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A106400</a>(a(n-1)) = 1. - <a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Apr 29 2012</div> <div class=sectline>a(n) = (a(n-1) + 2) XOR <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(a(n-1) + 2). - <a href="/wiki/User:Falk_H眉ffner">Falk H眉ffner</a>, Jan 21 2022</div> <div class=sectline>a(n+1) = <a href="/A006068" title="a(n) is Gray-coded into n.">A006068</a>(n) XOR (2*<a href="/A006068" title="a(n) is Gray-coded into n.">A006068</a>(n)). - <a href="/wiki/User:R茅my_Sigrist">R茅my Sigrist</a>, Apr 14 2022</div> </div> </div> <div class=section> <div class=sectname>MAPLE</div> <div class=sectbody> <div class=sectline>s := proc(n) local i, j, ans; ans := [ ]; j := 0; for i from 0 while j<n do if add(k, k=convert(i, base, 2)) mod 2=0 then ans := [ op(ans), i ]; j := j+1; fi; od; RETURN(ans); end; t1 := s(100); <a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a> := n->t1[n]; # s(k) gives first k terms.</div> <div class=sectline># Alternative:</div> <div class=sectline>seq(`if`(add(k, k=convert(n, base, 2))::even, n, NULL), n=0..129); # <a href="/wiki/User:Peter_Luschny">Peter Luschny</a>, Jan 15 2021</div> <div class=sectline># alternative for use outside this sequence</div> <div class=sectline>isA001969 := proc(n)</div> <div class=sectline> add(d, d=convert(n, base, 2)) ;</div> <div class=sectline> type(%, 'even') ;</div> <div class=sectline>end proc:</div> <div class=sectline><a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a> := proc(n)</div> <div class=sectline> option remember ;</div> <div class=sectline> local a;</div> <div class=sectline> if n = 0 then</div> <div class=sectline> 1;</div> <div class=sectline> else</div> <div class=sectline> for a from procname(n-1)+1 do</div> <div class=sectline> if isA001969(a) then</div> <div class=sectline> return a;</div> <div class=sectline> end if;</div> <div class=sectline> end do:</div> <div class=sectline> end if;</div> <div class=sectline>end proc:</div> <div class=sectline>seq(<a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>(n), n=1..200) ; # <a href="/wiki/User:R._J._Mathar">R. J. Mathar</a>, Aug 07 2022</div> </div> </div> <div class=section> <div class=sectname>MATHEMATICA</div> <div class=sectbody> <div class=sectline>Select[Range[0, 300], EvenQ[DigitCount[ #, 2][[1]]] &]</div> <div class=sectline>a[ n_] := If[ n < 1, 0, With[{m = n - 1}, 2 m + Mod[-Total@IntegerDigits[m, 2], 2]]]; (* <a href="/wiki/User:Michael_Somos">Michael Somos</a>, Jun 09 2019 *)</div> </div> </div> <div class=section> <div class=sectname>PROG</div> <div class=sectbody> <div class=sectline>(PARI) a(n)=n-=1; 2*n+subst(Pol(binary(n)), x, 1)%2</div> <div class=sectline>(PARI) a(n)=if(n<1, 0, if(n%2==0, a(n/2)+n, -a((n-1)/2)+3*n))</div> <div class=sectline>(PARI) a(n)=2*(n-1)+hammingweight(n-1)%2 \\ <a href="/wiki/User:Charles_R_Greathouse_IV">Charles R Greathouse IV</a>, Mar 22 2013</div> <div class=sectline>(Magma) [ n : n in [0..129] | IsEven(&+Intseq(n, 2)) ]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006</div> <div class=sectline>(Haskell)</div> <div class=sectline>a001969 n = a001969_list !! (n-1)</div> <div class=sectline>a001969_list = [x | x <- [0..], even $ a000120 x]</div> <div class=sectline>-- <a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Feb 01 2012</div> <div class=sectline>(Python)</div> <div class=sectline>def ok(n): return bin(n)[2:].count('1') % 2 == 0</div> <div class=sectline>print(list(filter(ok, range(130)))) # <a href="/wiki/User:Michael_S._Branicky">Michael S. Branicky</a>, Jun 02 2021</div> <div class=sectline>(Python)</div> <div class=sectline>from itertools import chain, count, islice</div> <div class=sectline>def <a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>_gen(): # generator of terms</div> <div class=sectline> return chain((0, ), chain.from_iterable((sorted(n^ n<<1 for n in range(2**l, 2**(l+1))) for l in count(0))))</div> <div class=sectline><a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>_list = list(islice(<a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>_gen(), 30)) # <a href="/wiki/User:Chai_Wah_Wu">Chai Wah Wu</a>, Jun 29 2022</div> <div class=sectline>(Python)</div> <div class=sectline>def <a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>(n): return ((m:=n-1).bit_count()&1)+(m<<1) # <a href="/wiki/User:Chai_Wah_Wu">Chai Wah Wu</a>, Mar 03 2023</div> </div> </div> <div class=section> <div class=sectname>CROSSREFS</div> <div class=sectbody> <div class=sectline>Complement of <a href="/A000069" title="Odious numbers: numbers with an odd number of 1's in their binary expansion.">A000069</a> (the odious numbers). Cf. <a href="/A133009" title="One defining property of the sequences {A, B} = {A000069, A001969} is that they are the unique pair of sets complementary wi...">A133009</a>.</div> <div class=sectline>a(n)=2*n+<a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(n)=<a href="/A000069" title="Odious numbers: numbers with an odd number of 1's in their binary expansion.">A000069</a>(n)-(-1)^<a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>(n). Cf. <a href="/A018900" title="Sums of two distinct powers of 2.">A018900</a>.</div> <div class=sectline>The basic sequences concerning the binary expansion of n are <a href="/A000120" title="1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).">A000120</a>, <a href="/A000788" title="Total number of 1's in binary expansions of 0, ..., n.">A000788</a>, <a href="/A000069" title="Odious numbers: numbers with an odd number of 1's in their binary expansion.">A000069</a>, <a href="/A001969" title="Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.">A001969</a>, <a href="/A023416" title="Number of 0's in binary expansion of n.">A023416</a>, <a href="/A059015" title="Total number of 0's in binary expansions of 0, ..., n.">A059015</a>.</div> <div class=sectline>Cf. <a href="/A036585" title="Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b.">A036585</a> (differences), <a href="/A010060" title="Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtain...">A010060</a>, <a href="/A006364" title="Numbers k with an even number of 1's in binary, ignoring last bit.">A006364</a>.</div> <div class=sectline>For primes see <a href="/A027699" title="Evil primes: primes with even number of 1's in their binary expansion.">A027699</a>, also <a href="/A130593" title="Evil semiprimes.">A130593</a>.</div> <div class=sectline>Cf. <a href="/A006068" title="a(n) is Gray-coded into n.">A006068</a>, <a href="/A048724" title="Write n and 2n in binary and add them mod 2.">A048724</a>, <a href="/A059010" title="Natural numbers having an even number of nonleading zeros in their binary expansion.">A059010</a>, <a href="/A094677" title="Sum of digits is divisible by 10.">A094677</a>.</div> <div class=sectline>Sequence in context: <a href="/A165740" title="Positive integers n such that solution to the toric n X n "Lights Out" puzzle is not unique (up to the order of flippings; e...">A165740</a> <a href="/A241571" title="Numbers n such that 2*n+15 is not a prime.">A241571</a> <a href="/A080307" title="Multiples of the Fermat numbers 2^(2^n)+1.">A080307</a> * <a href="/A075311" title="a(1) = 1; for n > 1, a(n) is the smallest number m > a(n-1) such that the number of 1's in the binary expansion of m is not ...">A075311</a> <a href="/A032786" title="Numbers k such that k(k+1)(k+2)...(k+15) / (k+(k+1)+(k+2)+...+(k+15)) is an integer.">A032786</a> <a href="/A080309" title="n-th even number equals n-th multiple of a Fermat number.">A080309</a></div> <div class=sectline>Adjacent sequences: <a href="/A001966" title="v-pile counts for the 4-Wythoff game with i=2.">A001966</a> <a href="/A001967" title="u-pile positions for the 4-Wythoff game with i=3.">A001967</a> <a href="/A001968" title="v-pile positions of the 4-Wythoff game with i=3.">A001968</a> * <a href="/A001970" title="Functional determinants; partitions of partitions; Euler transform applied twice to all 1's sequence.">A001970</a> <a href="/A001971" title="Nearest integer to n^2/8.">A001971</a> <a href="/A001972" title="Expansion of 1/((1-x)^2*(1-x^4)) = 1/( (1+x)*(1+x^2)*(1-x)^3 ).">A001972</a></div> </div> </div> <div class=section> <div class=sectname>KEYWORD</div> <div class=sectbody> <div class=sectline><span title="it is very easy to produce terms of sequence">easy</span>,<span title="an important sequence">core</span>,<span title="a sequence of nonnegative numbers">nonn</span>,<span title="an exceptionally nice sequence">nice</span>,<span title="dependent on base used for sequence">base</span></div> </div> </div> <div class=section> <div class=sectname>AUTHOR</div> <div class=sectbody> <div class=sectline><a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a></div> </div> </div> <div class=section> <div class=sectname>EXTENSIONS</div> <div class=sectbody> <div class=sectline>More terms from Robin Trew (trew(AT)hcs.harvard.edu)</div> </div> </div> <div class=section> <div class=sectname>STATUS</div> <div class=sectbody> <div class=sectline>approved</div> </div> </div> </div> <div class=space10></div> </div> </div></div> <p> <div class=footerpad></div> <div class=footer> <center> <div class=bottom> <div class=linksbar> <a href="/">Lookup</a> <a href="/wiki/Welcome"><font color="red">Welcome</font></a> <a href="/wiki/Main_Page"><font color="red">Wiki</font></a> <a href="/wiki/Special:RequestAccount">Register</a> <a href="/play.html">Music</a> <a href="/plot2.html">Plot 2</a> <a href="/demo1.html">Demos</a> <a href="/wiki/Index_to_OEIS">Index</a> <a href="/webcam">WebCam</a> <a href="/Submit.html">Contribute</a> <a href="/eishelp2.html">Format</a> <a href="/wiki/Style_Sheet">Style Sheet</a> <a href="/transforms.html">Transforms</a> <a href="/ol.html">Superseeker</a> <a href="/recent">Recents</a> </div> <div class=linksbar> <a href="/community.html">The OEIS Community</a> </div> <div class=linksbar> Maintained by <a href="http://oeisf.org">The OEIS Foundation Inc.</a> </div> <div class=dbinfo>Last modified December 1 06:35 EST 2024. Contains 378277 sequences.</div> <div class=legal> <a href="/wiki/Legal_Documents">License Agreements, Terms of Use, Privacy Policy</a> </div> </div> </center> </div> </body> </html>