A003159 Numbers whose binary representation ends in an even number of zeros.
1, 3, 4, 5, 7, 9, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23, 25, 27, 28, 29, 31, 33, 35, 36, 37, 39, 41, 43, 44, 45, 47, 48, 49, 51, 52, 53, 55, 57, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 73, 75, 76, 77, 79, 80, 81, 83, 84, 85, 87, 89, 91, 92, 93, 95, 97, 99, 100, 101, 103, 105
Offset: 1
Examples
1=1, 3=11, 5=101 and 7=111 have no (0 = even) trailing zeros, 4=100 has 2 (= even) trailing zeros in the base-2 representation. 2=10 and 6=110 end in one (=odd number) of trailing zeros in their base-2 representation, therefore are not terms of this sequence. - _M. F. Hasler_, Oct 29 2013
References
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Lars Blomberg, Table of n, a(n) for n = 1..10000 (first 1000 terms from T. D. Noe)
- Jean-Paul Allouche, Thue, Combinatorics on words, and conjectures inspired by the Thue-Morse sequence, arXiv preprint arXiv:1401.3727 [math.NT], 2014.
- Jean-Paul Allouche, Thue, Combinatorics on words, and conjectures inspired by the Thue-Morse sequence, J. de Théorie des Nombres de Bordeaux, 27, no. 2 (2015), 375-388.
- Jean-Paul Allouche, On the morphism 1 -> 121, 2 -> 12221, CNRS France, 2024. See pp. 3, 6.
- Jean-Paul Allouche, On the morphism 1 -> 121, 2 -> 12221, Preprint, 2024 [Local copy, with permission]
- Jean-Paul Allouche, Andre Arnold, Jean Berstel, Srecko Brlek, William Jockusch, Simon Plouffe, and Bruce E. Sagan, A sequence related to that of Thue-Morse, Discrete Math., 139 (1995), 455-461.
- Jean-Paul Allouche and Jeffrey Shallit, The Ubiquitous Prouhet-Thue-Morse Sequence, in C. Ding. T. Helleseth and H. Niederreiter, eds., Sequences and Their Applications: Proceedings of SETA '98, Springer-Verlag, 1999, pp. 1-16.
- Jean-Paul Allouche, Jeffrey Shallit, and Guentcho Skordev, Self-generating sets, integers with missing blocks and substitutions, Discrete Math. 292 (2005) 1-15.
- George E. Andrews and David Newman, Binary Representations and Theta Functions, 2017.
- L. Carlitz, R. Scoville, and V. E. Hoggatt, Jr., Representations for a special sequence, Fib. Quart., 10 (1972), 499-518, 550.
- R. Clerico, P. Fabbri, and F. Ortenzio, Pericolosamente vicino a Collatz, Rudi Mathematici, N. 226 (Nov 2017), p. 14 (in Italian).
- Michael Domaratzki, Trajectory-based codes, Acta Informatica, Volume 40, Numbers 6-7 / May, 2004.
- Emeric Deutsch and Bruce E. Sagan, Congruences for Catalan and Motzkin numbers and related sequences, arXiv:math/0407326 [math.CO], 2004; J. Num. Theory 117 (2006), 191-215.
- Artūras Dubickas, On the distance from a rational power to the nearest integer, Journal of Number Theory, Volume 117, Issue 1, March 2006, pp. 222-239.
- Artūras Dubickas, On a sequence related to that of Thue-Morse and its applications, Discrete Math. 307 (2007), no. 9-10, 1082--1093. MR2292537 (2008b:11086).
- Aviezri S. Fraenkel, New games related to old and new sequences, INTEGERS, Electronic J. of Combinatorial Number Theory, Vol. 4, Paper G6, 2004.
- Aviezri S. Fraenkel, The vile, dopey, evil and odious game players, Discrete Math. 312 (2012), no. 1, 42-46.
- Aviezri S. Fraenkel, Home Page.
- Russell Jay Hendel, A Family of Sequences Generalizing the Thue Morse and Rudin Shapiro Sequences, arXiv:2505.20547 [cs.FL], 2025. See p. 3.
- Clark Kimberling, Problem E2850, Amer. Math. Monthly, 87 (1980), 671.
- Clark Kimberling, Complementary Equations, Journal of Integer Sequences, Vol. 10 (2007), Article 07.1.4.
- Clark Kimberling, Affinely recursive sets and orderings of languages, Discrete Math., 274 (2004), 147-160.
- N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences, Slides of talk given at Rutgers University, Feb. 2012.
- Jan Snellman, Greedy Regular Convolutions, arXiv:2504.02795 [math.NT], 2025.
- Eric Sopena, i-Mark: A new subtraction division game, arXiv:1509.04199 [cs.DM], 2015.
- David Wakeham and David R. Wood, On multiplicative Sidon sets, INTEGERS, 13 (2013), #A26.
- Index entries for 2-automatic sequences.
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Haskell
import Data.List (delete) a003159 n = a003159_list !! (n-1) a003159_list = f [1..] where f (x:xs) = x : f (delete (2*x) xs) -- Reinhard Zumkeller, Nov 04 2011
-
Maple
filter:= n -> type(padic:-ordp(n,2),even): select(filter,[$1..1000]); # Robert Israel, Jul 07 2014
-
Mathematica
f[n_Integer] := Block[{k = n, c = 0}, While[ EvenQ[k], c++; k /= 2]; c]; Select[ Range[105], EvenQ[ f[ # ]] & ] Select[Range[150],EvenQ[IntegerExponent[#,2]]&] (* Harvey P. Dale, Oct 19 2011 *)
-
PARI
a(n)=if(n<2,n>0,n=a(n-1); until(valuation(n,2)%2==0,n++); n)
-
PARI
is(n)=valuation(n,2)%2==0 \\ Charles R Greathouse IV, Sep 23 2012
-
Python
from itertools import count, islice def A003159_gen(startvalue=1): # generator of terms >= startvalue return filter(lambda n:(n&-n).bit_length()&1,count(max(startvalue,1))) A003159_list = list(islice(A003159_gen(),30)) # Chai Wah Wu, Jul 11 2022
-
Python
def A003159(n): def f(x): c, s = n+x, bin(x)[2:] l = len(s) for i in range(l&1^1,l,2): c -= int(s[i])+int('0'+s[:i],2) return c m, k = n, f(n) while m != k: m, k = k, f(k) return m # Chai Wah Wu, Jan 29 2025
Formula
a(0) = 1; for n >= 0, a(n+1) = a(n) + 1 if (a(n) + 1)/2 is not already in the sequence, = a(n) + 2 otherwise.
Limit_{n->oo} a(n)/n = 3/2. - Benoit Cloitre, Jun 13 2002
More precisely, a(n) = 3*n/2 + O(log n). - Charles R Greathouse IV, Sep 23 2012
a(n) = Sum_{k = 1..n} A026465(k). - Benoit Cloitre, May 31 2003
a(n+1) = (if a(n) mod 4 = 3 then A007814(a(n) + 1) mod 2 else a(n) mod 2) + a(n) + 1; a(1) = 1. - Reinhard Zumkeller, Aug 03 2003
a(A003157(n)) is even. - Philippe Deléham, Feb 22 2004
Sequence consists of numbers of the form 4^i*(2*j + 1), i>=0, j>=0. - Jon Perry, Jun 06 2004
G.f.: (1/(1-x)) * Product_{k >= 1} (1 + x^A001045(k)). - Paul Barry, Dec 09 2004
a(1) = 1, a(2) = 3, and for n >= 2 we get a(n+1) = 4 + a(n) + a(n-1) - a(a(n)-n+1) - a(a(n-1)-n+2). - Benoit Cloitre, Apr 08 2010
If A(x) is the counting function for a(n) <= x, then A(2^n) = (2^(n+1) + (-1)^n)/3. - Vladimir Shevelev, Apr 15 2010
a(n) = A121539(n) + 1. - Reinhard Zumkeller, Mar 01 2012
Extensions
Additional comments from Michael Somos
Edited by M. F. Hasler, Oct 29 2013
Incorrect formula removed by Peter Munn, Dec 04 2020
Comments