A030101 a(n) is the number produced when n is converted to binary digits, the binary digits are reversed and then converted back into a decimal number.
0, 1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 13, 3, 11, 7, 15, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63, 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57
Offset: 0
Examples
a(100) = 19 because 100 (base 10) = 1100100 (base 2) and R(1100100 (base 2)) = 10011 (base 2) = 19 (base 10).
References
- Hlawka E. The theory of uniform distribution. Academic Publishers, Berkhamsted, 1984. See pp. 93, 94 for the van der Corput sequence. - N. J. A. Sloane, Dec 01 2019
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
- Sean Anderson, Bit Twiddling Hacks, for fixed-width reversals.
- Joerg Arndt, Matters Computational (The Fxtbook), section 1.14 Reversing the bits of a word, page 33.
- Harold L. Dorwart, Seventeenth annual USA Mathematical Olympiads, Math. Mag., 62 (1989), 210-214 (#3).
- Bernd Fischer and Lothar Reichel, Newton interpolation in Fejér and Chebyshev points, Mathematics of Computation 53.187 (1989): 265-278. See pp. 266, 267 for the van der Corput sequence. - _N. J. A. Sloane_, Dec 01 2019
- Michael Gilleland, Some Self-Similar Integer Sequences
- E. Hlawka, The theory of uniform distribution. Academic Publishers, Berkhamsted, 1984. See pp. 93, 94 for the van der Corput sequence. - _N. J. A. Sloane_, Dec 01 2019
- Project Euler, Problem 463: A weird recurrence relation
- Wikipedia, van der Corput sequence.
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Haskell
a030101 = f 0 where f y 0 = y f y x = f (2 * y + b) x' where (x', b) = divMod x 2 -- Reinhard Zumkeller, Mar 18 2014, Oct 21 2011
-
J
([: #. [: |. #:)"0 NB. Stephen Makdisi, May 07 2018
-
Magma
A030101:=func
; // Jason Kimberley, Sep 19 2011 -
Maple
A030101 := proc(n) convert(n,base,2) ; ListTools[Reverse](%) ; add(op(i,%)*2^(i-1),i=1..nops(%)) ; end proc: # R. J. Mathar, Mar 10 2015 # second Maple program: a:= proc(n) local m, r; m:=n; r:=0; while m>0 do r:=r*2+irem(m, 2, 'm') od; r end: seq(a(n), n=0..80); # Alois P. Heinz, Nov 17 2015
-
Mathematica
Table[FromDigits[Reverse[IntegerDigits[i, 2]], 2], {i, 0, 80}] bitRev[n_] := Switch[Mod[n, 4], 0, bitRev[n/2], 1, 2 bitRev[(n + 1)/2] - bitRev[(n - 1)/4], 2, bitRev[n/2], 3, 3 bitRev[(n - 1)/2] - 2 bitRev[(n - 3)/4]]; bitRev[0] = 0; bitRev[1] = 1; bitRev[3] = 3; Array[bitRev, 80, 0] (* Robert G. Wilson v, Mar 18 2014 *)
-
PARI
a(n)=if(n<1,0,subst(Polrev(binary(n)),x,2))
-
PARI
a(n) = fromdigits(Vecrev(binary(n)), 2); \\ Michel Marcus, Nov 10 2017
-
Python
def a(n): return int(bin(n)[2:][::-1], 2) # Indranil Ghosh, Apr 24 2017
-
Sage
def A030101(n): return Integer(bin(n).lstrip("0b")[::-1],2) if n!=0 else 0 [A030101(n) for n in (0..78)] # Peter Luschny, Aug 09 2012
-
Scala
(0 to 127).map(n => Integer.parseInt(Integer.toString(n, 2).reverse, 2)) // Alonso del Arte, Feb 11 2020
Formula
a(n) = 0, a(2n) = a(n), a(2n+1) = a(n) + 2^(floor(log_2(n)) + 1). For n > 0, a(n) = 2*A030109(n) - 1. - Ralf Stephan, Sep 15 2003
a(n) = b(n, 0) with b(n, r) = r if n = 0, otherwise b(floor(n/2), 2*r + n mod 2). - Reinhard Zumkeller, Mar 03 2010
a(1) = 1, a(3) = 3, a(2n) = a(n), a(4n+1) = 2a(2n+1) - a(n), a(4n+3) = 3a(2n+1) - 2a(n) (as in the Project Euler problem). To prove this, expand the recurrence into binary strings and reversals. - David Applegate, Mar 16 2014, following a posting to the Sequence Fans Mailing List by Martin Møller Skarbiniks Pedersen.
Conjecture: a(n) = 2*w(n) - 2*w(A053645(n)) - 1 for n > 0, where w = A264596. - Velin Yanev, Sep 12 2017
Extensions
Edits (including correction of an erroneous date pointed out by J. M. Bergot) by Jon E. Schoenfield, Mar 16 2014
Name clarified by Antti Karttunen, Nov 09 2017
Comments