login
Search: a004760 -id:a004760
     Sort: relevance | references | number | modified | created      Format: long | short | data
a(n) = A161511(A004760(n)).
+20
3
1, 2, 4, 3, 6, 5, 6, 4, 8, 7, 8, 6, 9, 7, 8, 5, 10, 9, 10, 8, 11, 9, 10, 7, 12, 10, 11, 8, 12, 9, 10, 6, 12, 11, 12, 10, 13, 11, 12, 9, 14, 12, 13, 10, 14, 11, 12, 8, 15, 13, 14, 11, 15, 12, 13, 9, 16, 13, 14, 10, 15, 11, 12, 7, 14, 13, 14, 12, 15, 13, 14, 11, 16, 14, 15, 12, 16
OFFSET
1,2
COMMENTS
a(n) gives the one-based position of the first nonzero term on the row n-1 of A126441.
Sequence A016116 can be used to identify the extracted subsequence by computing the number of terms to alternately extract and skip. [This comment is from the original submitter. I don't understand it. - Antti Karttunen, Oct 12 2009]
PROG
(Python)
def A161920(n):
a, b = 1+(m:=n-1).bit_length(), 1
for i, j in enumerate(bin(m)[:1:-1], 1):
if int(j):
a += i-b
b += 1
return a # Chai Wah Wu, Jul 26 2023
CROSSREFS
a(n) = A161511(A004760(n)) = 1 + A055941(n-1) + A029837(n).
KEYWORD
nonn
AUTHOR
Alford Arnold, Jun 24 2009
EXTENSIONS
Edited and extended by Antti Karttunen, Oct 12 2009
STATUS
approved
a(n) = A004760(n+1)-A160217(n), n>=1.
+20
1
0, 0, 0, 3, 2, 0, 0, 6, 6, 4, 4, 3, 2, 0, 0, 15, 14, 12, 12, 11, 10, 8, 8, 6, 6, 4, 4, 3, 2, 0, 0, 30, 30, 28, 28, 27, 26, 24, 24, 22, 22, 20, 20, 19, 18, 16, 16, 15, 14, 12, 12, 11, 10, 8, 8, 6, 6, 4, 4, 3, 2, 0, 0, 63, 62, 60, 60, 59, 58, 56, 56, 54, 54, 52, 52, 51, 50
OFFSET
1,4
FORMULA
a(1)=0; a(2n)=a(2n+1)=2a(n) if A007814(n) is even, a(2n)=a(2n+1)+1=2a(n)+3 if A007814(n) is odd.
EXAMPLE
a(2)=2a(1)=0; a(3)=2a(1)=0; a(4)=2a(2)+3=3; a(5)=2a(2)+2=2.
PROG
(PARI) is0(n)= (n<2) || binary(n)[2]; \\ A004760
list0(nn) = select(x->is0(x), vector(nn, k, k));
list7(nn) = {my(va = vector(nn)); va[1] = 3; for (n=2, nn, va[n]= nexta(va[n-1], n); ); va; } \\ A160217
listd(nn) = {my(v7 = list7(nn), v0 = list0(nn)); vector(min(#v0-1, #v7), k, v0[k+1] - v7[k]); } \\ Michel Marcus, Dec 15 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Vladimir Shevelev, May 04 2009
EXTENSIONS
Edited by N. J. A. Sloane, May 08 2009
More terms from Michel Marcus, Dec 15 2018
STATUS
approved
Exponent of highest power of 2 dividing n, a.k.a. the binary carry sequence, the ruler sequence, or the 2-adic valuation of n.
+10
930
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
OFFSET
1,4
COMMENTS
This sequence is an exception to my usual rule that when every other term of a sequence is 0 then those 0's should be omitted. In this case we would get A001511. - N. J. A. Sloane
To construct the sequence: start with 0,1, concatenate to get 0,1,0,1. Add + 1 to last term gives 0,1,0,2. Concatenate those 4 terms to get 0,1,0,2,0,1,0,2. Add + 1 to last term etc. - Benoit Cloitre, Mar 06 2003
The sequence is invariant under the following two transformations: increment every element by one (1, 2, 1, 3, 1, 2, 1, 4, ...), put a zero in front and between adjacent elements (0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, ...). The intermediate result is A001511. - Ralf Hinze (ralf(AT)informatik.uni-bonn.de), Aug 26 2003
Fixed point of the morphism 0->01, 1->02, 2->03, 3->04, ..., n->0(n+1), ..., starting from a(1) = 0. - Philippe Deléham, Mar 15 2004
Fixed point of the morphism 0->010, 1->2, 2->3, ..., n->(n+1), .... - Joerg Arndt, Apr 29 2014
a(n) is also the number of times to repeat a step on an even number in the hailstone sequence referenced in the Collatz conjecture. - Alex T. Flood (whiteangelsgrace(AT)gmail.com), Sep 22 2006
Let F(n) be the n-th Fermat number (A000215). Then F(a(r-1)) divides F(n)+2^k for r = k mod 2^n and r != 1. - T. D. Noe, Jul 12 2007
The following relation holds: 2^A007814(n)*(2*A025480(n-1)+1) = A001477(n) = n. (See functions hd, tl and cons in [Paul Tarau 2009].)
a(n) is the number of 0's at the end of n when n is written in base 2.
a(n+1) is the number of 1's at the end of n when n is written in base 2. - M. F. Hasler, Aug 25 2012
Shows which bit to flip when creating the binary reflected Gray code (bits are numbered from the right, offset is 0). That is, A003188(n) XOR A003188(n+1) == 2^A007814(n). - Russ Cox, Dec 04 2010
The sequence is squarefree (in the sense of not containing any subsequence of the form XX) [Allouche and Shallit]. Of course it contains individual terms that are squares (such as 4). - Comment expanded by N. J. A. Sloane, Jan 28 2019
a(n) is the number of zero coefficients in the n-th Stern polynomial, A125184. - T. D. Noe, Mar 01 2011
Lemma: For n < m with r = a(n) = a(m) there exists n < k < m with a(k) > r. Proof: We have n=b2^r and m=c2^r with b < c both odd; choose an even i between them; now a(i2^r) > r and n < i2^r < m. QED. Corollary: Every finite run of consecutive integers has a unique maximum 2-adic valuation. - Jason Kimberley, Sep 09 2011
a(n-2) is the 2-adic valuation of A000166(n) for n >= 2. - Joerg Arndt, Sep 06 2014
a(n) = number of 1's in the partition having Heinz number n. We define the Heinz number of a partition p = [p_1, p_2, ..., p_r] as Product_{j=1..r} p_j-th prime (concept used by Alois P. Heinz in A215366 as an "encoding" of a partition). For example, for the partition [1, 1, 2, 4, 10] we get 2*2*3*7*29 = 2436. Example: a(24)=3; indeed, the partition having Heinz number 24 = 2*2*2*3 is [1,1,1,2]. - Emeric Deutsch, Jun 04 2015
a(n+1) is the difference between the two largest parts in the integer partition having viabin number n (0 is assumed to be a part). Example: a(20) = 2. Indeed, we have 19 = 10011_2, leading to the Ferrers board of the partition [3,1,1]. For the definition of viabin number see the comment in A290253. - Emeric Deutsch, Aug 24 2017
Apart from being squarefree, as noted above, the sequence has the property that every consecutive subsequence contains at least one number an odd number of times. - Jon Richfield, Dec 20 2018
a(n+1) is the 2-adic valuation of Sum_{e=0..n} u^e = (1 + u + u^2 + ... + u^n), for any u of the form 4k+1 (A016813). - Antti Karttunen, Aug 15 2020
{a(n)} represents the "first black hat" strategy for the game of countably infinitely many hats, with a probability of success of 1/3; cf. the Numberphile link below. - Frederic Ruget, Jun 14 2021
a(n) is the least nonnegative integer k for which there does not exist i+j=n and a(i)=a(j)=k (cf. A322523). - Rémy Sigrist and Jianing Song, Aug 23 2022
REFERENCES
J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 27.
K. Atanassov, On the 37th and the 38th Smarandache Problems, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 5 (1999), No. 2, 83-85.
Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.
LINKS
Joerg Arndt, Subset-lex: did we miss an order?, arXiv:1405.6503 [math.CO], 2014.
Alain Connes, Caterina Consani, and Henri Moscovici, Zeta zeros and prolate wave operators, arXiv:2310.18423 [math.NT], 2023.
Dario T. de Castro, P-adic Order of Positive Integers via Binomial Coefficients, INTEGERS, Electronic J. of Combinatorial Number Theory, Vol. 22, Paper A61, 2022.
Mathieu Guay-Paquet and Jeffrey Shallit, Avoiding Squares and Overlaps Over the Natural Numbers, (2009) Discrete Math., 309 (2009), 6245-6254.
Mathieu Guay-Paquet and Jeffrey Shallit, Avoiding Squares and Overlaps Over the Natural Numbers, arXiv:0901.1397 [math.CO], 2009.
M. Hassani, Equations and inequalities involving v_p(n!), J. Inequ. Pure Appl. Math. 6 (2005) vol. 2, #29.
A. M. Hinz, S. Klavžar, U. Milutinović, and C. Petr, The Tower of Hanoi - Myths and Maths, Birkhäuser 2013. See page 61. Book's website
R. Hinze, Concrete stream calculus: An extended study, J. Funct. Progr. 20 (5-6) (2010) 463-535, doi, Section 3.2.3.
Clark Kimberling, Affinely recursive sets and orderings of languages, Discrete Math., 274 (2004), 147-160.
Francis Laclé, 2-adic parity explorations of the 3n+ 1 problem, hal-03201180v2 [cs.DM], 2021.
Nicolas Mallet, Trial for a proof of the Syracuse conjecture, arXiv preprint arXiv:1507.05039 [math.GM], 2015.
S. Mazzanti, Plain Bases for Classes of Primitive Recursive Functions, Mathematical Logic Quarterly, 48 (2002).
Matthew Andres Moreno, Luis Zaman, and Emily Dolson, Structured Downsampling for Fast, Memory-efficient Curation of Online Data Streams, arXiv:2409.06199 [cs.DS], 2024. See p. 5.
Sascha Mücke, Coding Nuggets Faster QUBO Brute-Force Solving, TU Dortmund Univ. (Germany 2023).
S. Northshield, An Analogue of Stern's Sequence for Z[sqrt(2)], Journal of Integer Sequences, 18 (2015), #15.11.6.
Giovanni Pighizzini, Limited Automata: Properties, Complexity and Variants, International Conference on Descriptional Complexity of Formal Systems (DCFS 2019) Descriptional Complexity of Formal Systems, Lecture Notes in Computer Science (LNCS, Vol. 11612) Springer, Cham, 57-73.
Simon Plouffe, On the values of the functions ... [zeta and Gamma] ..., arXiv preprint arXiv:1310.7195 [math.NT], 2013.
A. Postnikov (MIT) and B. Sagan, What power of two divides a weighted Catalan number?, arXiv:math/0601339 [math.CO], 2006.
Lara Pudwell and Eric Rowland, Avoiding fractional powers over the natural numbers, arXiv:1510.02807 [math.CO] (2015). Also Electronic Journal of Combinatorics, Volume 25(2) (2018), #P2.27. See Section 2.
Ville Salo, Decidability and Universality of Quasiminimal Subshifts, arXiv preprint arXiv:1411.6644 [math.DS], 2014.
Vladimir Shevelev, Several results on sequences which are similar to the positive integers, arXiv:0904.2101 [math.NT], 2014.
Paul Tarau, A Groupoid of Isomorphic Data Transformations. Calculemus 2009, 8th International Conference, MKM 2009, pp. 170-185, Springer, LNAI 5625.
P. M. B. Vitanyi, An optimal simulation of counter machines, SIAM J. Comput, 14:1(1985), 1-33.
Eric Weisstein's World of Mathematics, Binary, Binary Carry Sequence, and Double-Free Set.
Wikipedia, P-adic order.
FORMULA
a(n) = A001511(n) - 1.
a(2*n) = A050603(2*n) = A001511(n).
a(n) = A091090(n-1) + A036987(n-1) - 1.
a(n) = 0 if n is odd, otherwise 1 + a(n/2). - Reinhard Zumkeller, Aug 11 2001
Sum_{k=1..n} a(k) = n - A000120(n). - Benoit Cloitre, Oct 19 2002
G.f.: A(x) = Sum_{k>=1} x^(2^k)/(1-x^(2^k)). - Ralf Stephan, Apr 10 2002
G.f. A(x) satisfies A(x) = A(x^2) + x^2/(1-x^2). A(x) = B(x^2) = B(x) - x/(1-x), where B(x) is the g.f. for A001151. - Franklin T. Adams-Watters, Feb 09 2006
Totally additive with a(p) = 1 if p = 2, 0 otherwise.
Dirichlet g.f.: zeta(s)/(2^s-1). - Ralf Stephan, Jun 17 2007
Define 0 <= k <= 2^n - 1; binary: k = b(0) + 2*b(1) + 4*b(2) + ... + 2^(n-1)*b(n-1); where b(x) are 0 or 1 for 0 <= x <= n - 1; define c(x) = 1 - b(x) for 0 <= x <= n - 1; Then: a(k) = c(0) + c(0)*c(1) + c(0)*c(1)*c(2) + ... + c(0)*c(1)...c(n-1); a(k+1) = b(0) + b(0)*b(1) + b(0)*b(1)*b(2) + ... + b(0)*b(1)...b(n-1). - Arie Werksma (werksma(AT)tiscali.nl), May 10 2008
a(n) = floor(A002487(n - 1) / A002487(n)). - Reikku Kulon, Oct 05 2008
Sum_{k=1..n} (-1)^A000120(n-k)*a(k) = (-1)^(A000120(n)-1)*(A000120(n) - A000035(n)). - Vladimir Shevelev, Mar 17 2009
a(A001147(n) + A057077(n-1)) = a(2*n). - Vladimir Shevelev, Mar 21 2009
For n>=1, a(A004760(n+1)) = a(n). - Vladimir Shevelev, Apr 15 2009
2^(a(n)) = A006519(n). - Philippe Deléham, Apr 22 2009
a(n) = A063787(n) - A000120(n). - Gary W. Adamson, Jun 04 2009
a(C(n,k)) = A000120(k) + A000120(n-k) - A000120(n). - Vladimir Shevelev, Jul 19 2009
a(n!) = n - A000120(n). - Vladimir Shevelev, Jul 20 2009
v_{2}(n) = Sum_{r>=1} (r / 2^(r+1)) Sum_{k=0..2^(r+1)-1} e^(2(k*Pi*i(n+2^r))/(2^(r+1))). - A. Neves, Sep 28 2010, corrected Oct 04 2010
a(n) mod 2 = A096268(n-1). - Robert G. Wilson v, Jan 18 2012
a(A005408(n)) = 1; a(A016825(n)) = 3; A017113(a(n)) = 5; A051062(a(n)) = 7; a(n) = (A037227(n)-1)/2. - Reinhard Zumkeller, Jun 30 2012
a((2*n-1)*2^p) = p, p >= 0 and n >= 1. - Johannes W. Meijer, Feb 04 2013
a(n) = A067255(n,1). - Reinhard Zumkeller, Jun 11 2013
a(n) = log_2(n - (n AND n-1)). - Gary Detlefs, Jun 13 2014
a(n) = 1 + A000120(n-1) - A000120(n), where A000120 is the Hamming weight function. - Stanislav Sykora, Jul 14 2014
A053398(n,k) = a(A003986(n-1,k-1)+1); a(n) = A053398(n,1) = A053398(n,n) = A053398(2*n-1,n) = Min_{k=1..n} A053398(n,k). - Reinhard Zumkeller, Aug 04 2014
a((2*x-1)*2^n) = a((2*y-1)*2^n) for positive n, x and y. - Juri-Stepan Gerasimov, Aug 04 2016
a(n) = A285406(n) - A281264(n). - Ralf Steiner, Apr 18 2017
a(n) = A000005(n)/(A000005(2*n) - A000005(n)) - 1. - conjectured by Velin Yanev, Jun 30 2017, proved by Nicholas Stearns, Sep 11 2017
Equivalently to above formula, a(n) = A183063(n) / A001227(n), i.e., a(n) is the number of even divisors of n divided by number of odd divisors of n. - Franklin T. Adams-Watters, Oct 31 2018
a(n)*(n mod 4) = 2*floor(((n+1) mod 4)/3). - Gary Detlefs, Feb 16 2019
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1. - Amiram Eldar, Jul 11 2020
a(n) = 2*Sum_{j=1..floor(log_2(n))} frac(binomial(n, 2^j)*2^(j-1)/n). - Dario T. de Castro, Jul 08 2022
a(n) = A070939(n) - A070939(A030101(n)). - Andrew T. Porter, Dec 16 2022
a(n) = floor((gcd(n, 2^n)^(n+1) mod (2^(n+1)-1)^2)/(2^(n+1)-1)) (see Lemma 3.4 from Mazzanti's 2002 article). - Lorenzo Sauras Altuzarra, Mar 10 2024
a(n) = 1 - A088705(n). - Chai Wah Wu, Sep 18 2024
EXAMPLE
2^3 divides 24, so a(24)=3.
From Omar E. Pol, Jun 12 2009: (Start)
Triangle begins:
0;
1,0;
2,0,1,0;
3,0,1,0,2,0,1,0;
4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0;
5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0;
6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,...
(End)
MAPLE
ord := proc(n) local i, j; if n=0 then return 0; fi; i:=0; j:=n; while j mod 2 <> 1 do i:=i+1; j:=j/2; od: i; end proc: seq(ord(n), n=1..111);
A007814 := n -> padic[ordp](n, 2): seq(A007814(n), n=1..111); # Peter Luschny, Nov 26 2010
MATHEMATICA
Table[IntegerExponent[n, 2], {n, 64}] (* Eric W. Weisstein *)
IntegerExponent[Range[64], 2] (* Eric W. Weisstein, Feb 01 2024 *)
p=2; Array[ If[ Mod[ #, p ]==0, Select[ FactorInteger[ # ], Function[ q, q[ [ 1 ] ]==p ], 1 ][ [ 1, 2 ] ], 0 ]&, 96 ]
DigitCount[BitXor[x, x - 1], 2, 1] - 1; a different version based on the same concept: Floor[Log[2, BitXor[x, x - 1]]] (* Jaume Simon Gispert (jaume(AT)nuem.com), Aug 29 2004 *)
Nest[Join[ #, ReplacePart[ #, Length[ # ] -> Last[ # ] + 1]] &, {0, 1}, 5] (* N. J. Gunther, May 23 2009 *)
Nest[ Flatten[# /. a_Integer -> {0, a + 1}] &, {0}, 7] (* Robert G. Wilson v, Jan 17 2011 *)
PROG
(PARI) A007814(n)=valuation(n, 2);
(Haskell)
a007814 n = if m == 0 then 1 + a007814 n' else 0
where (n', m) = divMod n 2
-- Reinhard Zumkeller, Jul 05 2013, May 14 2011, Apr 08 2011
(Haskell)
a007814 n | odd n = 0 | otherwise = 1 + a007814 (n `div` 2)
-- Walt Rorie-Baety, Mar 22 2013
(R) sapply(1:100, function(x) sum(gmp::factorize(x)==2)) # Christian N. K. Anderson, Jun 20 2013
(Magma) [Valuation(n, 2): n in [1..120]]; // Bruno Berselli, Aug 05 2013
(Python)
import math
def a(n): return int(math.log(n - (n & n - 1), 2)) # Indranil Ghosh, Apr 18 2017
(Python)
def A007814(n): return (~n & n-1).bit_length() # Chai Wah Wu, Jul 01 2022
(Scheme) (define (A007814 n) (let loop ((n n) (e 0)) (if (odd? n) e (loop (/ n 2) (+ 1 e))))) ;; Antti Karttunen, Oct 06 2017
CROSSREFS
Cf. A011371 (partial sums), A094267 (first differences), A346070 (mod 4).
Bisection of A050605 and |A088705|. Pairwise sums are A050603 and A136480. Difference of A285406 and A281264.
This is Guy Steele's sequence GS(1, 4) (see A135416). Cf. A053398(1,n). Column/row 1 of table A050602.
Cf. A007949 (3-adic), A112765 (5-adic), A122841 (6-adic), A214411 (7-adic), A122840 (10-adic).
Cf. A086463 (Dgf at s=2).
KEYWORD
nonn,nice,easy
AUTHOR
John Tromp, Dec 11 1996
EXTENSIONS
Formula index adapted to the offset of A025480 by R. J. Mathar, Jul 20 2010
Edited by Ralf Stephan, Feb 08 2014
STATUS
approved
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 obtained from A_k by interchanging 0's and 1's.
+10
575
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1
OFFSET
0,1
COMMENTS
Named after Axel Thue, whose name is pronounced as if it were spelled "Tü" where the ü sound is roughly as in the German word üben. (It is incorrect to say "Too-ee" or "Too-eh".) - N. J. A. Sloane, Jun 12 2018
Also called the Thue-Morse infinite word, or the Morse-Hedlund sequence, or the parity sequence.
Fixed point of the morphism 0 --> 01, 1 --> 10, see example. - Joerg Arndt, Mar 12 2013
The sequence is cubefree (does not contain three consecutive identical blocks) [see Offner for a direct proof] and is overlap-free (does not contain XYXYX where X is 0 or 1 and Y is any string of 0's and 1's).
a(n) = "parity sequence" = parity of number of 1's in binary representation of n.
To construct the sequence: alternate blocks of 0's and 1's of successive lengths A003159(k) - A003159(k-1), k = 1, 2, 3, ... (A003159(0) = 0). Example: since the first seven differences of A003159 are 1, 2, 1, 1, 2, 2, 2, the sequence starts with 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0. - Emeric Deutsch, Jan 10 2003
Characteristic function of A000069 (odious numbers). - Ralf Stephan, Jun 20 2003
a(n) = S2(n) mod 2, where S2(n) = sum of digits of n, n in base-2 notation. There is a class of generalized Thue-Morse sequences: Let Sk(n) = sum of digits of n; n in base-k notation. Let F(t) be some arithmetic function. Then a(n)= F(Sk(n)) mod m is a generalized Thue-Morse sequence. The classical Thue-Morse sequence is the case k=2, m=2, F(t)= 1*t. - Ctibor O. Zizka, Feb 12 2008 (with correction from Daniel Hug, May 19 2017)
More generally, the partial sums of the generalized Thue-Morse sequences a(n) = F(Sk(n)) mod m are fractal, where Sk(n) is sum of digits of n, n in base k; F(t) is an arithmetic function; m integer. - Ctibor O. Zizka, Feb 25 2008
Starting with offset 1, = running sums mod 2 of the kneading sequence (A035263, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, ...); also parity of A005187: (1, 3, 4, 7, 8, 10, 11, 15, 16, 18, 19, ...). - Gary W. Adamson, Jun 15 2008
Generalized Thue-Morse sequences mod n (n>1) = the array shown in A141803. As n -> infinity the sequences -> (1, 2, 3, ...). - Gary W. Adamson, Jul 10 2008
The Thue-Morse sequence for N = 3 = A053838, (sum of digits of n in base 3, mod 3): (0, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, ...) = A004128 mod 3. - Gary W. Adamson, Aug 24 2008
For all positive integers k, the subsequence a(0) to a(2^k-1) is identical to the subsequence a(2^k+2^(k-1)) to a(2^(k+1)+2^(k-1)-1). That is to say, the first half of A_k is identical to the second half of B_k, and the second half of A_k is identical to the first quarter of B_{k+1}, which consists of the k/2 terms immediately following B_k.
Proof: The subsequence a(2^k+2^(k-1)) to a(2^(k+1)-1), the second half of B_k, is by definition formed from the subsequence a(2^(k-1)) to a(2^k-1), the second half of A_k, by interchanging its 0's and 1's. In turn, the subsequence a(2^(k-1)) to a(2^k-1), the second half of A_k, which is by definition also B_{k-1}, is by definition formed from the subsequence a(0) to a(2^(k-1)-1), the first half of A_k, which is by definition also A_{k-1}, by interchanging its 0's and 1's. Interchanging the 0's and 1's of a subsequence twice leaves it unchanged, so the subsequence a(2^k+2^(k-1)) to a(2^(k+1)-1), the second half of B_k, must be identical to the subsequence a(0) to a(2^(k-1)-1), the first half of A_k.
Also, the subsequence a(2^(k+1)) to a(2^(k+1)+2^(k-1)-1), the first quarter of B_{k+1}, is by definition formed from the subsequence a(0) to a(2^(k-1)-1), the first quarter of A_{k+1}, by interchanging its 0's and 1's. As noted above, the subsequence a(2^(k-1)) to a(2^k-1), the second half of A_k, which is by definition also B_{k-1}, is by definition formed from the subsequence a(0) to a(2^(k-1)-1), which is by definition A_{k-1}, by interchanging its 0's and 1's, as well. If two subsequences are formed from the same subsequence by interchanging its 0's and 1's then they must be identical, so the subsequence a(2^(k+1)) to a(2^(k+1)+2^(k-1)-1), the first quarter of B_{k+1}, must be identical to the subsequence a(2^(k-1)) to a(2^k-1), the second half of A_k.
Therefore the subsequence a(0), ..., a(2^(k-1)-1), a(2^(k-1)), ..., a(2^k-1) is identical to the subsequence a(2^k+2^(k-1)), ..., a(2^(k+1)-1), a(2^(k+1)), ..., a(2^(k+1)+2^(k-1)-1), QED.
According to the German chess rules of 1929 a game of chess was drawn if the same sequence of moves was repeated three times consecutively. Euwe, see the references, proved that this rule could lead to infinite games. For his proof he reinvented the Thue-Morse sequence. - Johannes W. Meijer, Feb 04 2010
"Thue-Morse 0->01 & 1->10, at each stage append the previous with its complement. Start with 0, 1, 2, 3 and write them in binary. Next calculate the sum of the digits (mod 2) - that is divide the sum by 2 and use the remainder." Pickover, The Math Book.
Let s_2(n) be the sum of the base-2 digits of n and epsilon(n) = (-1)^s_2(n), the Thue-Morse sequence, then prod(n >= 0, ((2*n+1)/(2*n+2))^epsilon(n) ) = 1/sqrt(2). - Jonathan Vos Post, Jun 06 2012
Dekking shows that the constant obtained by interpreting this sequence as a binary expansion is transcendental; see also "The Ubiquitous Prouhet-Thue-Morse Sequence". - Charles R Greathouse IV, Jul 23 2013
Drmota, Mauduit, and Rivat proved that the subsequence a(n^2) is normal--see A228039. - Jonathan Sondow, Sep 03 2013
Although the probability of a 0 or 1 is equal, guesses predicated on the latest bit seen produce a correct match 2 out of 3 times. - Bill McEachen, Mar 13 2015
From a(0) to a(2n+1), there are n+1 terms equal to 0 and n+1 terms equal to 1 (see Hassan Tarfaoui link, Concours Général 1990). - Bernard Schott, Jan 21 2022
REFERENCES
J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 15.
Jason Bell, Michael Coons, and Eric Rowland, "The Rational-Transcendental Dichotomy of Mahler Functions", Journal of Integer Sequences, Vol. 16 (2013), #13.2.10.
J. Berstel and J. Karhumaki, Combinatorics on words - a tutorial, Bull. EATCS, #79 (2003), pp. 178-228.
B. Bollobas, The Art of Mathematics: Coffee Time in Memphis, Cambridge, 2006, p. 224.
S. Brlek, Enumeration of factors in the Thue-Morse word, Discrete Applied Math., 24 (1989), 83-96. doi:10.1016/0166-218X(92)90274-E.
Yann Bugeaud and Guo-Niu Han, A combinatorial proof of the non-vanishing of Hankel determinants of the Thue-Morse sequence, Electronic Journal of Combinatorics 21(3) (2014), #P3.26.
Y. Bugeaud and M. Queffélec, On Rational Approximation of the Binary Thue-Morse-Mahler Number, Journal of Integer Sequences, 16 (2013), #13.2.3.
Currie, James D. "Non-repetitive words: Ages and essences." Combinatorica 16.1 (1996): 19-40
Colin Defant, Anti-Power Prefixes of the Thue-Morse Word, Journal of Combinatorics, 24(1) (2017), #P1.32
F. M. Dekking, Transcendance du nombre de Thue-Morse, Comptes Rendus de l'Academie des Sciences de Paris 285 (1977), pp. 157-160.
F. M. Dekking, On repetitions of blocks in binary sequences. J. Combinatorial Theory Ser. A 20 (1976), no. 3, pp. 292-299. MR0429728(55 #2739)
Dekking, Michel, Michel Mendès France, and Alf van der Poorten. "Folds." The Mathematical Intelligencer, 4.3 (1982): 130-138 & front cover, and 4:4 (1982): 173-181 (printed in two parts).
Dubickas, Artūras. On a sequence related to that of Thue-Morse and its applications. Discrete Math. 307 (2007), no. 9-10, 1082--1093. MR2292537 (2008b:11086).
Fabien Durand, Julien Leroy, and Gwenaël Richomme, "Do the Properties of an S-adic Representation Determine Factor Complexity?", Journal of Integer Sequences, Vol. 16 (2013), #13.2.6.
M. Euwe, Mengentheoretische Betrachtungen Über das Schachspiel, Proceedings Koninklijke Nederlandse Akademie van Wetenschappen, Amsterdam, Vol. 32 (5): 633-642, 1929.
S. Ferenczi, Complexity of sequences and dynamical systems, Discrete Math., 206 (1999), 145-154.
S. R. Finch, Mathematical Constants, Cambridge, 2003, Section 6.8.
W. H. Gottschalk and G. A. Hedlund, Topological Dynamics. American Mathematical Society, Colloquium Publications, Vol. 36, Providence, RI, 1955, p. 105.
J. Grytczuk, Thue type problems for graphs, points and numbers, Discrete Math., 308 (2008), 4419-4429.
A. Hof, O. Knill and B. Simon, Singular continuous spectrum for palindromic Schroedinger operators, Commun. Math. Phys. 174 (1995), 149-159.
Mari Huova and Juhani Karhumäki, "On Unavoidability of k-abelian Squares in Pure Morphic Words", Journal of Integer Sequences, Vol. 16 (2013), #13.2.9.
B. Kitchens, Review of "Computational Ergodic Theory" by G. H. Choe, Bull. Amer. Math. Soc., 44 (2007), 147-155.
Le Breton, Xavier, Linear independence of automatic formal power series. Discrete Math. 306 (2006), no. 15, 1776-1780.
M. Lothaire, Combinatorics on Words. Addison-Wesley, Reading, MA, 1983, p. 23.
Donald MacMurray, A mathematician gives an hour to chess, Chess Review 6 (No. 10, 1938), 238. [Discusses Marston's 1938 article]
Mauduit, Christian. Multiplicative properties of the Thue-Morse sequence. Period. Math. Hungar. 43 (2001), no. 1-2, 137--153. MR1830572 (2002i:11081)
C. A. Pickover, Wonders of Numbers, Adventures in Mathematics, Mind and Meaning, Chapter 17, 'The Pipes of Papua,' Oxford University Press, Oxford, England, 2000, pages 34-38.
C. A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 60.
Clifford A. Pickover, The Math Book, From Pythagoras to the 57th Dimension, 250 Milestones in the History of Mathematics, Sterling Publ., NY, 2009, page 316.
Narad Rampersad and Elise Vaslet, "On Highly Repetitive and Power Free Words", Journal of Integer Sequences, Vol. 16 (2013), #13.2.7.
G. Richomme, K. Saari, L. Q. Zamboni, Abelian complexity in minimal subshifts, J. London Math. Soc. 83(1) (2011) 79-95.
Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.
M. Rigo, P. Salimov, and E. Vandomme, "Some Properties of Abelian Return Words", Journal of Integer Sequences, Vol. 16 (2013), #13.2.5.
Benoit Rittaud, Elise Janvresse, Emmanuel Lesigne and Jean-Christophe Novelli, Quand les maths se font discrètes, Le Pommier, 2008 (ISBN 978-2-7465-0370-0).
A. Salomaa, Jewels of Formal Language Theory. Computer Science Press, Rockville, MD, 1981, p. 6.
Shallit, J. O. "On Infinite Products Associated with Sums of Digits." J. Number Th. 21, 128-134, 1985.
Ian Stewart, "Feedback", Mathematical Recreations Column, Scientific American, 274 (No. 3, 1996), page 109 [Historical notes on this sequence]
Thomas Stoll, On digital blocks of polynomial values and extractions in the Rudin-Shapiro sequence, RAIRO - Theoretical Informatics and Applications (RAIRO: ITA), EDP Sciences, 2016, 50, pp. 93-99. <hal-01278708>.
A. Thue. Über unendliche Zeichenreihen, Norske Vid. Selsk. Skr. I. Mat. Nat. Kl. Christiania, No. 7 (1906), 1-22.
A. Thue, Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen, Norske Vid. Selsk. Skr. I. Mat. Nat. Kl. Christiania, 1 (1912), 1-67.
S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 890.
LINKS
A. G. M. Ahmed, AA Weaving. In: Proceedings of Bridges 2013: Mathematics, Music, Art, ..., 2013.
A. Aksenov, The Newman phenomenon and Lucas sequence, arXiv preprint arXiv:1108.5352 [math.NT], 2011-2012.
Max A. Alekseyev and N. J. A. Sloane, On Kaprekar's Junction Numbers, arXiv:2112.14365, 2021; Journal of Combinatorics and Number Theory 12:3 (2022), 115-155.
J.-P. Allouche, Series and infinite products related to binary expansions of integers, Behaviour, 4.4 (1992): p. 5.
J.-P. Allouche, Lecture notes on automatic sequences, Krakow October 2013.
J.-P. 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 p. 3.
Jean-Paul Allouche, On the morphism 1 -> 121, 2 -> 12221, Preprint, 2024 [Local copy, with permission]
J.-P. Allouche, Andre Arnold, Jean Berstel, Srecko Brlek, William Jockusch, Simon Plouffe and Bruce E. Sagan, A relative of the Thue-Morse sequence, Discrete Math., 139 (1995), 455-461.
Jean-Paul Allouche, Julien Cassaigne, Jeffrey Shallit and Luca Q. Zamboni, A Taxonomy of Morphic Sequences, arXiv preprint arXiv:1711.10807 [cs.FL], Nov 29 2017.
J.-P. Allouche and H. Cohen, Dirichlet Series and Curious Infinite Products, Bull. London Math. Soc. 17, 531-538, 1985.
J.-P. Allouche and T. Johnson, Narayana's cows and delayed morphisms, in G. Assayag, M. Chemillier, and C. Eloy, Troisièmes Journées d'Informatique Musicale, JIM '96, Île de Tatihou, France, 1996, pp. 2-7. [The hal link does not always work. - N. J. A. Sloane, Feb 19 2025]
J.-P. Allouche and T. Johnson, Narayana's cows and delayed morphisms, in G. Assayag, M. Chemillier, and C. Eloy, Troisièmes Journées d'Informatique Musicale, JIM '96, Île de Tatihou, France, 1996, pp. 2-7. [Local copy with annotations and a correction from N. J. A. Sloane, Feb 19 2025]
J.-P. Allouche and M. Mendes France, Automata and Automatic Sequences, in: Axel F. and Gratias D. (eds), Beyond Quasicrystals. Centre de Physique des Houches, vol 3. Springer, Berlin, Heidelberg, pp. 293-367, 1995; DOI https://doi.org/10.1007/978-3-662-03130-8_11.
J.-P. Allouche and M. Mendes France, Automata and Automatic Sequences, in: Axel F. and Gratias D. (eds), Beyond Quasicrystals. Centre de Physique des Houches, vol 3. Springer, Berlin, Heidelberg, pp. 293-367, 1995; DOI https://doi.org/10.1007/978-3-662-03130-8_11. [Local copy]
J.-P. 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.
J.-P. Allouche and J. Shallit, The Ring of k-regular Sequences, II, Theoretical Computer Science 307.1 (2003): 3-29. doi:10.1016/S0304-3975(03)00090-2
Jorge Almeida and Ondrej Klíma, Binary patterns in the Prouhet-Thue-Morse sequence, arXiv:1904.07137 [math.CO], 2019.
G. N. Arzhantseva, C. H. Cashen, D. Gruber and D. Hume, Contracting geodesics in infinitely presented graphical small cancellation groups, arXiv preprint arXiv:1602.03767 [math.GR], 2016-2018.
Ricardo Astudillo, On a Class of Thue-Morse Type Sequences, J. Integer Seqs., Vol. 6, 2003.
F. Axel et al., Vibrational modes in a one dimensional "quasi-alloy": the Morse case, J. de Physique, Colloq. C3, Supp. to No. 7, Vol. 47 (Jul 1986), pp. C3-181-C3-186; see Eq. (10).
M. Baake, U. Grimm and J. Nilsson, Scaling of the Thue-Morse diffraction measure, arXiv preprint arXiv:1311.4371 [math-ph], 2013.
Scott Balchin and Dan Rust, Computations for Symbolic Substitutions, Journal of Integer Sequences, Vol. 20 (2017), Article 17.4.1.
Lucilla Baldini and Josef Eschgfäller, Random functions from coupled dynamical systems, arXiv preprint arXiv:1609.01750 [math.CO], 2016. See Example 3.11.
J. Berstel, Axel Thue's papers on repetitions in words: a translation, July 21 1994. Publications du LaCIM, Département de mathématiques et d'informatique 20, Université du Québec à Montréal, 1995, 85 pages. [Cached copy]
J.-F. Bertazzon, Resolution of an integral equation with the Thue-Morse sequence, arXiv:1201.2502v1 [math.CO], Jan 12, 2012.
J. Cooper and A. Dutle, Greedy Galois Games, Amer. Math. Mnthly, 120 (2013), 441-451.
Françoise Dejean, Sur un Théorème de Thue, J. Combinatorial Theory, vol. 13 A, iss. 1 (1972) 90-99.
F. Michel Dekking, Morphisms, Symbolic sequences, and their Standard Forms, arXiv:1509.00260 [math.CO], 2015.
F. M. Dekking, The Thue-Morse Sequence in Base 3/2, J. Int. Seq., Vol. 26 (2023), Article 23.2.3.
A. de Luca and S. Varricchio, Some combinatorial properties of the Thue-Morse sequence and a problem in semigroups, Theoret. Comput. Sci. 63 (1989), 333-348.
E. Deutsch and B. E. Sagan, Congruences for Catalan and Motzkin numbers and related sequences, J. Num. Theory 117 (2006), 191-215.
M. Drmota, C. Mauduit and J. Rivat, The Thue-Morse Sequence Along The Squares is Normal, Abstract, ÖMG-DMV Congress, 2013.
Arthur Dolgopolov, Equitable Sequencing and Allocation Under Uncertainty, Preprint, 2016.
J. Endrullis, D. Hendriks and J. W. Klop, Degrees of streams, Journal of Integers B 11 (2011): 1-40..
A. S. Fraenkel, New games related to old and new sequences, INTEGERS, Electronic J. of Combinatorial Number Theory, Vol. 4, Paper G6, 2004.
Hao Fu and G.-N. Han, Computer assisted proof for Apwenian sequences related to Hankel determinants, arXiv preprint arXiv:1601.04370 [math.NT], 2016.
Maciej Gawro and Maciej Ulas, "On formal inverse of the Prouhet-Thue-Morse sequence." Discrete Mathematics 339.5 (2016): 1459-1470. Also arXiv:1601.04840, 2016.
Daniel Goc, Luke Schaeffer and Jeffrey Shallit, The Subword Complexity of k-Automatic Sequences is k-Synchronized, arXiv 1206.5352 [cs.FL], Jun 28 2012.
G. A. Hedlund, Remarks on the work of Axel Thue on sequences, Nordisk Mat. Tid., 15 (1967), 148-150.
Dimitri Hendriks, Frits G. W. Dannenberg, Jorg Endrullis, Mark Dow and Jan Willem Klop, Arithmetic Self-Similarity of Infinite Sequences, arXiv preprint 1201.3786 [math.CO], 2012.
A. M. Hinz, S. Klavžar, U. Milutinović and C. Petr, The Tower of Hanoi - Myths and Maths, Birkhäuser 2013. See page 79. Website for book
Denis Janković, Rémi Pasquier, Jean-Gabriel Hartmann, and Paul-Antoine Hervieux, Elucidating the Physical and Mathematical Properties of the Prouhet-Thue-Morse Sequence in Quantum Computing, arXiv:2501.09610 [quant-ph], 2025. See p. 17.
Tanya Khovanova, There are no coincidences, arXiv preprint 1410.2193 [math.CO], 2014.
Clark Kimberling, Intriguing infinite words composed of zeros and ones, Elemente der Mathematik (2021).
Naoki Kobayashi, Kazutaka Matsuda and Ayumi Shinohara, Functional Programs as Compressed Data, Higher-Order and Symbolic Computation, 25, no. 1 (2012): 39-84..
Philip Lafrance, Narad Rampersad and Randy Yee, Some properties of a Rudin-Shapiro-like sequence, arXiv:1408.2277 [math.CO], 2014.
C. Mauduit and J. Rivat, La somme des chiffres des carrés, Acta Mathem. 203 (1) (2009) 107-148.
Harold Marston Morse, Recurrent geodesics on a surface of negative curvature, Trans. Amer. Math. Soc., 22 (1921), 84-100.
F. Mignosi, A. Restivo, and M. Sciortino, Words and forbidden factors, WORDS (Rouen, 1999). Theoret. Comput. Sci. 273 (2002), no. 1-2, 99--117. MR1872445 (2002m:68096).
Marston Morse, A solution of the problem of infinite play in chess, (review), Bull. Amer. Math. Soc., 44 (No. 9, 1938), p. 632. [Mentions an application to chess]
K. Nakano, Shall We Juggle, Coinductively?, in Certified Programs and Proofs, Lecture Notes in Computer Science Volume 7679, 2012, pp. 160-172.
Hieu D. Nguyen, A mixing of Prouhet-Thue-Morse sequences and Rademacher functions, arXiv preprint arXiv:1405.6958 [math.NT], 2014.
Hieu D. Nguyen, A Generalization of the Digital Binomial Theorem , J. Int. Seq. 18 (2015) # 15.5.7.
C. D. Offner, Repetitions of Words and the Thue-Morse sequence. Preprint, no date.
Matt Parker, The Fairest Sharing Sequence Ever, YouTube video, Nov 27 2015
A. Parreau, M. Rigo, E. Rowland and E. Vandomme, A new approach to the 2-regularity of the l-abelian complexity of 2-automatic sequences, arXiv preprint arXiv:1405.3532 [cs.FL], 2014.
C. A. Pickover, "Wonders of Numbers, Adventures in Mathematics, Mind and Meaning," Zentralblatt review
Saúl Pilatowsky-Cameo, Soonwon Choi, and Wen Wei Ho, Critically slow Hilbert-space ergodicity in quantum morphic drives, arXiv:2502.06936 [quant-ph], 2025. See pp. 6, 15.
E. Prouhet, Mémoire sur quelques relations entre les puissances des nombres, Comptes Rendus Acad. des Sciences, 33 (No. 8, 1851), p. 225. [Said to implicitly mention this sequence]
Michel Rigo, Relations on words, arXiv preprint arXiv:1602.03364 [cs.FL], 2016.
Luke Schaeffer and Jeffrey Shallit, Closed, Palindromic, Rich, Privileged, Trapezoidal, and Balanced Words in Automatic Sequences, Electronic Journal of Combinatorics 23(1) (2016), #P1.25.
M. R. Schroeder & N. J. A. Sloane, Correspondence, 1991
R. Schroeppel and R. W. Gosper, HACKMEM #122 (1972).
Vladimir Shevelev, Two analogs of Thue-Morse sequence, arXiv preprint arXiv:1603.04434 [math.NT], 2016-2017.
L. Spiegelhofer, Normality of the Thue-Morse Sequence along Piatetski-Shapiro sequences, Quart. J. Math. 66 (3) (2015).
Hassan Tarfaoui, Concours Général 1990 - Exercice 1 (in French).
Eric Weisstein's World of Mathematics, Thue-Morse Sequence
Eric Weisstein's World of Mathematics, Thue-Morse Constant
Eric Weisstein's World of Mathematics, Parity
Joost Winter, Marcello M. Bonsangue, and Jan J. M. M. Rutten, Context-free coalgebras, Journal of Computer and System Sciences, 81.5 (2015): 911-939.
Hans Zantema, Complexity of Automatic Sequences, International Conference on Language and Automata Theory and Applications (LATA 2020): Language and Automata Theory and Applications, 260-271.
FORMULA
a(2n) = a(n), a(2n+1) = 1 - a(n), a(0) = 0. Also, a(k+2^m) = 1 - a(k) if 0 <= k < 2^m.
If n = Sum b_i*2^i is the binary expansion of n then a(n) = Sum b_i (mod 2).
Let S(0) = 0 and for k >= 1, construct S(k) from S(k-1) by mapping 0 -> 01 and 1 -> 10; sequence is S(infinity).
G.f.: (1/(1 - x) - Product_{k >= 0} (1 - x^(2^k)))/2. - Benoit Cloitre, Apr 23 2003
a(0) = 0, a(n) = (n + a(floor(n/2))) mod 2; also a(0) = 0, a(n) = (n - a(floor(n/2))) mod 2. - Benoit Cloitre, Dec 10 2003
a(n) = -1 + (Sum_{k=0..n} binomial(n,k) mod 2) mod 3 = -1 + A001316(n) mod 3. - Benoit Cloitre, May 09 2004
Let b(1) = 1 and b(n) = b(ceiling(n/2)) - b(floor(n/2)) then a(n-1) = (1/2)*(1 - b(2n-1)). - Benoit Cloitre, Apr 26 2005
a(n) = 1 - A010059(n) = A001285(n) - 1. - Ralf Stephan, Jun 20 2003
a(n) = A001969(n) - 2n. - Franklin T. Adams-Watters, Aug 28 2006
a(n) = A115384(n) - A115384(n-1) for n > 0. - Reinhard Zumkeller, Aug 26 2007
For n >= 0, a(A004760(n+1)) = 1 - a(n). - Vladimir Shevelev, Apr 25 2009
a(A160217(n)) = 1 - a(n). - Vladimir Shevelev, May 05 2009
a(n) == A000069(n) (mod 2). - Robert G. Wilson v, Jan 18 2012
a(n) = A000035(A000120(n)). - Omar E. Pol, Oct 26 2013
a(n) = A000035(A193231(n)). - Antti Karttunen, Dec 27 2013
a(n) + A181155(n-1) = 2n for n >= 1. - Clark Kimberling, Oct 06 2014
G.f. A(x) satisfies: A(x) = x / (1 - x^2) + (1 - x) * A(x^2). - Ilya Gutkovskiy, Jul 29 2021
From Bernard Schott, Jan 21 2022: (Start)
a(n) = a(n*2^k) for k >= 0.
a((2^m-1)^2) = (1-(-1)^m)/2 (see Hassan Tarfaoui link, Concours Général 1990). (End)
EXAMPLE
The evolution starting at 0 is:
0
0, 1
0, 1, 1, 0
0, 1, 1, 0, 1, 0, 0, 1
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
.......
A_2 = 0 1 1 0, so B_2 = 1 0 0 1 and A_3 = A_2 B_2 = 0 1 1 0 1 0 0 1.
From Joerg Arndt, Mar 12 2013: (Start)
The first steps of the iterated substitution are
Start: 0
Rules:
0 --> 01
1 --> 10
-------------
0: (#=1)
0
1: (#=2)
01
2: (#=4)
0110
3: (#=8)
01101001
4: (#=16)
0110100110010110
5: (#=32)
01101001100101101001011001101001
6: (#=64)
0110100110010110100101100110100110010110011010010110100110010110
(End)
From Omar E. Pol, Oct 28 2013: (Start)
Written as an irregular triangle in which row lengths is A011782, the sequence begins:
0;
1;
1,0;
1,0,0,1;
1,0,0,1,0,1,1,0;
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1;
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0;
It appears that: row j lists the first A011782(j) terms of A010059, with j >= 0; row sums give A166444 which is also 0 together with A011782; right border gives A000035.
(End)
MAPLE
s := proc(k) local i, ans; ans := [ 0, 1 ]; for i from 0 to k do ans := [ op(ans), op(map(n->(n+1) mod 2, ans)) ] od; return ans; end; t1 := s(6); A010060 := n->t1[n]; # s(k) gives first 2^(k+2) terms.
a := proc(k) b := [0]: for n from 1 to k do b := subs({0=[0, 1], 1=[1, 0]}, b) od: b; end; # a(k), after the removal of the brackets, gives the first 2^k terms. # Example: a(3); gives [[[[0, 1], [1, 0]], [[1, 0], [0, 1]]]]
A010060:=proc(n)
add(i, i=convert(n, base, 2)) mod 2 ;
end proc:
seq(A010060(n), n=0..104); # Emeric Deutsch, Mar 19 2005
map(`-`, convert(StringTools[ThueMorse](1000), bytes), 48); # Robert Israel, Sep 22 2014
MATHEMATICA
Table[ If[ OddQ[ Count[ IntegerDigits[n, 2], 1]], 1, 0], {n, 0, 100}];
mt = 0; Do[ mt = ToString[mt] <> ToString[(10^(2^n) - 1)/9 - ToExpression[mt] ], {n, 0, 6} ]; Prepend[ RealDigits[ N[ ToExpression[mt], 2^7] ] [ [1] ], 0]
Mod[ Count[ #, 1 ]& /@Table[ IntegerDigits[ i, 2 ], {i, 0, 2^7 - 1} ], 2 ] (* Harlan J. Brothers, Feb 05 2005 *)
Nest[ Flatten[ # /. {0 -> {0, 1}, 1 -> {1, 0}}] &, {0}, 7] (* Robert G. Wilson v Sep 26 2006 *)
a[n_] := If[n == 0, 0, If[Mod[n, 2] == 0, a[n/2], 1 - a[(n - 1)/2]]] (* Ben Branman, Oct 22 2010 *)
a[n_] := Mod[Length[FixedPointList[BitAnd[#, # - 1] &, n]], 2] (* Jan Mangaldan, Jul 23 2015 *)
Table[2/3 (1 - Cos[Pi/3 (n - Sum[(-1)^Binomial[n, k], {k, 1, n}])]), {n, 0, 100}] (* or, for version 10.2 or higher *) Table[ThueMorse[n], {n, 0, 100}] (* Vladimir Reshetnikov, May 06 2016 *)
ThueMorse[Range[0, 100]] (* The program uses the ThueMorse function from Mathematica version 11 *) (* Harvey P. Dale, Aug 11 2016 *)
Nest[Join[#, 1 - #] &, {0}, 7] (* Paolo Xausa, Oct 25 2024 *)
PROG
(Haskell)
a010060 n = a010060_list !! n
a010060_list =
0 : interleave (complement a010060_list) (tail a010060_list)
where complement = map (1 - )
interleave (x:xs) ys = x : interleave ys xs
-- Doug McIlroy (doug(AT)cs.dartmouth.edu), Jun 29 2003
-- Edited by Reinhard Zumkeller, Oct 03 2012
(PARI) a(n)=if(n<1, 0, sum(k=0, length(binary(n))-1, bittest(n, k))%2)
(PARI) a(n)=if(n<1, 0, subst(Pol(binary(n)), x, 1)%2)
(PARI) default(realprecision, 6100); x=0.0; m=20080; for (n=1, m-1, x=x+x; x=x+sum(k=0, length(binary(n))-1, bittest(n, k))%2); x=2*x/2^m; for (n=0, 20000, d=floor(x); x=(x-d)*2; write("b010060.txt", n, " ", d)); \\ Harry J. Smith, Apr 28 2009
(PARI) a(n)=hammingweight(n)%2 \\ Charles R Greathouse IV, Mar 22 2013
(Python)
A010060_list = [0]
for _ in range(14):
A010060_list += [1-d for d in A010060_list] # Chai Wah Wu, Mar 04 2016
(Python)
def A010060(n): return n.bit_count()&1 # Chai Wah Wu, Mar 01 2023
(R)
maxrow <- 8 # by choice
b01 <- 1
for(m in 0:maxrow) for(k in 0:(2^m-1)){
b01[2^(m+1)+ k] <- b01[2^m+k]
b01[2^(m+1)+2^m+k] <- 1-b01[2^m+k]
}
(b01 <- c(0, b01))
# Yosu Yurramendi, Apr 10 2017
CROSSREFS
Cf. A001285 (for 1, 2 version), A010059 (for 1, 0 version), A106400 (for +1, -1 version), A048707. A010060(n)=A000120(n) mod 2.
Cf. A007413, A080813, A080814, A036581, A108694. See also the Thue (or Roth) constant A014578, also A014571.
Run lengths give A026465. Backward first differences give A029883.
Cf. A004128, A053838, A059448, A171900, A161916, A214212, A005942 (subword complexity), A010693 (Abelian complexity), A225186 (squares), A228039 (a(n^2)), A282317.
Sequences mentioned in the Allouche et al. "Taxonomy" paper, listed by example number: 1: A003849, 2: A010060, 3: A010056, 4: A020985 and A020987, 5: A191818, 6: A316340 and A273129, 18: A316341, 19: A030302, 20: A063438, 21: A316342, 22: A316343, 23: A003849 minus its first term, 24: A316344, 25: A316345 and A316824, 26: A020985 and A020987, 27: A316825, 28: A159689, 29: A049320, 30: A003849, 31: A316826, 32: A316827, 33: A316828, 34: A316344, 35: A043529, 36: A316829, 37: A010060.
KEYWORD
nonn,core,easy,nice
STATUS
approved
Distance to largest power of 2 less than or equal to n; write n in binary, change the first digit to zero, and convert back to decimal.
+10
90
0, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
OFFSET
1,6
COMMENTS
Triangle read by rows in which row n lists the first 2^n nonnegative integers (A001477), n >= 0. Right border gives A000225. Row sums give A006516. See example. - Omar E. Pol, Oct 17 2013
Without the initial zero also: zeroless numbers in base 3 (A032924: 1, 2, 11, 12, 21, ...), ternary digits decreased by 1 and read as binary. - M. F. Hasler, Jun 22 2020
LINKS
J.-P. Allouche and J. Shallit, The ring of k-regular sequences, preprint, Theoretical Computer Sci., 98 (1992), 163-197.
J.-P. Allouche and J. Shallit, The ring of k-regular sequences, Theoretical Computer Sci., 98 (1992), 163-197 (see Ex. 24).
FORMULA
a(n) = n - 2^A000523(n).
G.f.: 1/(1-x) * ((2x-1)/(1-x) + Sum_{k>=1} 2^(k-1)*x^2^k). - Ralf Stephan, Apr 18 2003
a(n) = (A006257(n)-1)/2. - N. J. A. Sloane, May 16 2003
a(1) = 0, a(2n) = 2a(n), a(2n+1) = 2a(n) + 1. - N. J. A. Sloane, Sep 13 2003
a(n) = A062050(n) - 1. - N. J. A. Sloane, Jun 12 2004
a(A004760(n+1)) = n. - Reinhard Zumkeller, May 20 2009
a(n) = f(n-1,1) with f(n,m) = if n < m then n else f(n-m,2*m). - Reinhard Zumkeller, May 20 2009
Conjecture: a(n) = (1 - A036987(n-1))*(1 + a(n-1)) for n > 1 with a(1) = 0. - Mikhail Kurkov, Jul 16 2019
EXAMPLE
From Omar E. Pol, Oct 17 2013: (Start)
Written as an irregular triangle the sequence begins:
0;
0,1;
0,1,2,3;
0,1,2,3,4,5,6,7;
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
...
(End)
MAPLE
seq(n - 2^ilog2(n), n=1..1000); # Robert Israel, Dec 23 2015
MATHEMATICA
Table[n - 2^Floor[Log2[n]], {n, 100}] (* IWABUCHI Yu(u)ki, May 25 2017 *)
Table[FromDigits[Rest[IntegerDigits[n, 2]], 2], {n, 100}] (* IWABUCHI Yu(u)ki, May 25 2017 *)
PROG
(Haskell)
a053645 1 = 0
a053645 n = 2 * a053645 n' + b where (n', b) = divMod n 2
-- Reinhard Zumkeller, Aug 28 2014
a053645_list = concatMap (0 `enumFromTo`) a000225_list
-- Reinhard Zumkeller, Feb 04 2013, Mar 23 2012
(PARI) a(n)=n-2^(#binary(n)-1) \\ Charles R Greathouse IV, Sep 02 2015
(Magma) [n - 2^Ilog2(n): n in [1..70]]; // Vincenzo Librandi, Jul 18 2019
(Python)
def a(n): return n - 2**(n.bit_length()-1)
print([a(n) for n in range(1, 85)]) # Michael S. Branicky, Jul 03 2021
(Python)
def A053645(n): return n&(1<<n.bit_length()-1)-1 # Chai Wah Wu, Jan 22 2023
KEYWORD
nonn,base,easy
AUTHOR
Henry Bottomley, Mar 22 2000
STATUS
approved
Numbers n whose binary expansion starts 10.
+10
30
2, 4, 5, 8, 9, 10, 11, 16, 17, 18, 19, 20, 21, 22, 23, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 128, 129, 130, 131
OFFSET
1,1
COMMENTS
A000120(a(n)) = A000120(n); A023416(a(n-1)) = A008687(n) for n > 1. - Reinhard Zumkeller, Dec 04 2015
FORMULA
a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + [n==0].
a(n) = n + 2^floor(log_2(n)) = n + A053644(n).
a(2^m+k) = 2^(m+1) + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 08 2016
EXAMPLE
10 in binary is 1010, so 10 is in sequence.
MATHEMATICA
w = {1, 0}; Select[Range[2, 131], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] == w] &] (* Michael De Vlieger, Aug 08 2016 *)
PROG
(PARI) a(n)=n+2^floor(log(n)/log(2))
(PARI) is(n)=n>1 && !binary(n)[2] \\ Charles R Greathouse IV, Sep 23 2012
(Haskell)
import Data.List (transpose)
a004754 n = a004754_list !! (n-1)
a004754_list = 2 : concat (transpose [zs, map (+ 1) zs])
where zs = map (* 2) a004754_list
-- Reinhard Zumkeller, Dec 04 2015
(Python)
def A004754(n): return n+(1<<n.bit_length()-1) # Chai Wah Wu, Jul 13 2022
CROSSREFS
Cf. A123001 (binary version), A004755 (11), A004756 (100), A004757 (101), A004758 (110), A004759 (111).
Apart from initial terms, same as A004761.
KEYWORD
nonn,easy,base
EXTENSIONS
Edited by Ralf Stephan, Oct 12 2003
STATUS
approved
Binary expansion starts 11.
+10
24
3, 6, 7, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122
OFFSET
1,1
COMMENTS
a(n) is the smallest value > a(n-1) (or > 1 for n=1) for which A001511(a(n)) = A001511(n). - Franklin T. Adams-Watters, Oct 23 2006
LINKS
Kenny Lau, Table of n, a(n) for n = 1..16383 (first 1023 terms from T. D. Noe)
FORMULA
a(2n) = 2*a(n), a(2n+1) = 2*a(n) + 1 + 2*[n==0].
a(n) = n + 2 * 2^floor(log_2(n)) = A004754(n) + A053644(n).
a(n) = 2n + A080079(n). - Benoit Cloitre, Feb 22 2003
G.f.: (1/(1+x)) * (1 + Sum_{k>=0, t=x^2^k} 2^k*(2t+t^2)/(1+t)).
a(n) = n + 2^(floor(log_2(n)) + 1) = n + A062383(n). - Franklin T. Adams-Watters, Oct 23 2006
a(2^m+k) = 2^(m+1) + 2^m + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 08 2016
EXAMPLE
12 in binary is 1100, so 12 is in the sequence.
MAPLE
a:= proc(n) n+2*2^floor(log(n)/log(2)) end: seq(a(n), n=1..60); # Muniru A Asiru, Oct 16 2018
MATHEMATICA
Flatten[Table[FromDigits[#, 2]&/@(Join[{1, 1}, #]&/@Tuples[{0, 1}, n]), {n, 0, 5}]] (* Harvey P. Dale, Feb 05 2015 *)
PROG
(PARI) a(n)=n+2*2^floor(log(n)/log(2))
(PARI) is(n)=n>2 && binary(n)[2] \\ Charles R Greathouse IV, Sep 23 2012
(Haskell)
import Data.List (transpose)
a004755 n = a004755_list !! (n-1)
a004755_list = 3 : concat (transpose [zs, map (+ 1) zs])
where zs = map (* 2) a004755_list
-- Reinhard Zumkeller, Dec 04 2015
(Python)
f = open('b004755.txt', 'w')
lo = 3
hi = 4
i = 1
while i<16384:
for x in range(lo, hi):
f.write(str(i)+" "+str(x)+"\n")
i += 1
lo <<= 1
hi <<= 1
# Kenny Lau, Jul 05 2016
(Python)
def A004755(n): return n+(1<<n.bit_length()) # Chai Wah Wu, Jul 13 2022
CROSSREFS
Equals union of A079946 and A080565.
Cf. A004754 (10), A004756 (100), A004757 (101), A004758 (110), A004759 (111).
KEYWORD
nonn,base,easy
EXTENSIONS
Edited by Ralf Stephan, Oct 12 2003
STATUS
approved
Permutation of natural numbers: sequence A126441 without zeros.
+10
15
1, 2, 3, 4, 5, 7, 8, 9, 6, 11, 15, 16, 17, 10, 19, 13, 23, 31, 32, 33, 18, 35, 12, 21, 14, 39, 27, 47, 63, 64, 65, 34, 67, 20, 37, 22, 71, 25, 43, 29, 79, 55, 95, 127, 128, 129, 66, 131, 36, 69, 38, 135, 24, 41, 26, 75, 45, 30, 143, 51, 87, 59, 159, 111, 191, 255, 256
OFFSET
1,2
COMMENTS
Values appear in the order determined by A004760(n+1)and A062383(n).
The graph of this sequence looks very elegant.
EXAMPLE
The table begins:
1.2.4..8.16.32.64.128.256.512.1024
..3.5..9.17.33.65.129.257.513.1025
.......6.10.18.34..66.130.258..514
....7.11.19.35.67.131.259.515.1027
............12.20..36..68.132..260
.........13.21.37..69.133.261..517
............14.22..38..70.134..262
......15.23.39.71.135.263.519.1031
...................24..40..72..136
...............25..41..73.137..265
...................26..42..74..138
............27.43..75.139.267..523
.......................28..44...76
...............29..45..77.141..269
...................30..46..78..142
.........31.47.79.143.271.527.1039
...........................48...80
.......................49..81..145
...........................50...82
...................51..83.147..275
This can be viewed as an irregular table, where row r (>= 1) has A000041(r) elements, that is, as 1; 2,3; 4,5,7; 8,9,6,11,15; 16,17,10,19,13,23,31; etc. A125106 illustrates how each number is mapped to a partition.
MATHEMATICA
columns = 9; row[n_] := n - 2^Floor[Log2[n]]; col[0] = 0; col[n_] := If[EvenQ[n], col[n/2] + DigitCount[n/2, 2, 1], col[(n - 1)/2] + 1]; Clear[T]; T[_, _] = 0; Do[T[row[k], col[k]] = k, {k, 1, 2^columns}]; Table[DeleteCases[Table[T[n - 1, k], {n, 1, 2^(k - 1)}], 0], {k, 1, columns}] // Flatten (* Jean-François Alcover, Sep 09 2017 *)
CROSSREFS
Inverse: A166276. a(n) = A126441(A166274(n)). See A161919 for the version with each row sorted into ascending order.
A161511(a(n)) = A036042(n).
KEYWORD
nonn,tabf,look
AUTHOR
Alford Arnold, Jun 23 2009
EXTENSIONS
Edited and extended by Antti Karttunen, Oct 12 2009
STATUS
approved
Tabular arrangement of the natural numbers: the row on which any nonzero term a(n) appears in is A053645(a(n))=A053645(n+1), and the column is A161511(a(n)). Table is presented by columns with 2^{k-1} items in column k, unused positions are filled with 0's.
+10
12
1, 2, 3, 4, 5, 0, 7, 8, 9, 6, 11, 0, 0, 0, 15, 16, 17, 10, 19, 0, 13, 0, 23, 0, 0, 0, 0, 0, 0, 0, 31, 32, 33, 18, 35, 12, 21, 14, 39, 0, 0, 0, 27, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 64, 65, 34, 67, 20, 37, 22, 71, 0, 25, 0, 43, 0, 29, 0, 79, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0
OFFSET
0,2
COMMENTS
Note: 1 might be a more natural starting offset for this sequence, although the identities concerning A053645 and A161511 would have to be changed. - Antti Karttunen, Oct 12 2009.
This can be regarded as an arrangement of the partitions, indexed by position in A125106. The partitions in a given row all have the same remaining partition when the largest part is removed; specifically, the partition indexed by the row number in A125106 (with row 0 having the empty partition remaining).
The first value on row n is A004760(n+1). The second value on each row is A004760(n+1) plus A062383(n); subsequent values increase by ever enlarging powers of two. Or equivalently, each subsequent value on the row after the first nonzero value is given by A004754(previous value on the same row).
A055941(r) tells how many terms the row r (>= 0) has been shifted rightward from its "natural position", i.e. with how many zeros that row has been prepended.
The number of (nonzero) entries in column k is A000041(k).
EXAMPLE
The largest power of 2 <= 6 is 4, 6 - 4 = 2, so 6 is in row 2. By A125106, 6 corresponds to the partition [2^2], total 4, so 6 goes in column 4. Thus T(2,4) = 6.
The table begins:
1.2.4..8.16.32.64.128.256.512.1024
..3.5..9.17.33.65.129.257.513.1025
.......6.10.18.34..66.130.258..514
....7.11.19.35.67.131.259.515.1027
............12.20..36..68.132..260
.........13.21.37..69.133.261..517
............14.22..38..70.134..262
......15.23.39.71.135.263.519.1031
...................24..40..72..136
...............25..41..73.137..265
...................26..42..74..138
............27.43..75.139.267..523
.......................28..44...76
...............29..45..77.141..269
...................30..46..78..142
.........31.47.79.143.271.527.1039
...........................48...80
.......................49..81..145
...........................50...82
...................51..83.147..275
MATHEMATICA
columns = 7; row[n_] := n-2^Floor[Log2[n]]; col[0] = 0; col[n_] := If[EvenQ[n], col[n/2] + DigitCount[n/2, 2, 1], col[(n-1)/2]+1]; Clear[T]; T[_, _] = 0; Do[T[row[k], col[k]] = k, {k, 1, 2^columns}]; Table[T[n-1, k], {k, 1, columns}, {n, 1, 2^(k-1)}] // Flatten (* Jean-François Alcover, Sep 09 2017 *)
PROG
(MIT/GNU Scheme)
(define (A126441 n) (A126441onebased (1+ n)))
(definec (A126441onebased n) (cond ((< n 2) n) (else (let ((prev (A126441onebased (- n (/ (A053644 n) 2))))) (if (or (= (A053644 n) (* 2 (A053644 (A053645 n)))) (zero? prev)) (let ((starter (A004760 (1+ (A053645 n))))) (if (> (A161511 starter) (1+ (A000523 n))) 0 starter)) (A004754 prev))))))
CROSSREFS
Cf. A125106, A053645, A000041, A004760, A062383, A000079 (column lengths).
A053645(a(A166274(n))) = A053645(1+A166274(n)) for all n>=1.
Positions of zeros: A166275, this sequence without zeros: A161924. A161920(n) gives the position of the first nonzero term on the row n-1.
KEYWORD
nonn,tabf
AUTHOR
Alford Arnold, Jan 19 2007
EXTENSIONS
Edited by Franklin T. Adams-Watters, Jan 23 2007
Further edited and Scheme-code added by Antti Karttunen, Oct 12 2009
STATUS
approved
Binary expansion starts 101.
+10
10
5, 10, 11, 20, 21, 22, 23, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185
OFFSET
1,1
LINKS
FORMULA
a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + 4*[n==0].
a(n) = n + 4 * 2^floor(log_2(n)) = A004756(n) + A053644(n).
a(2^m+k) = 5*2^m + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 08 2016
EXAMPLE
22 in binary is 10110, so 22 is in sequence.
MATHEMATICA
Table[n + 4*2^Floor@ Log2@ n, {n, 57}] (* or *)
w = {1, 0, 1}; Select[Range[5, 185], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] == w] &] (* Michael De Vlieger, Aug 10 2016 *)
Select[Range[5, 200], Take[IntegerDigits[#, 2], 3]=={1, 0, 1}&] (* Harvey P. Dale, Aug 26 2016 *)
PROG
(PARI) a(n)=n+4*2^floor(log(n)/log(2))
(Haskell)
import Data.List (transpose)
a004757 n = a004757_list !! (n-1)
a004757_list = 5 : concat (transpose [zs, map (+ 1) zs])
where zs = map (* 2) a004757_list
-- Reinhard Zumkeller, Dec 04 2015
(Python)
def A004757(n): return n+(2<<n.bit_length()) # Chai Wah Wu, Jul 13 2022
CROSSREFS
Cf. A004754 (10), A004755 (11), A004756 (100), A004758 (110), A004759 (111).
KEYWORD
nonn,base,easy
EXTENSIONS
Edited by Ralf Stephan, Oct 12 2003
STATUS
approved

Search completed in 0.032 seconds