login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A309873 Period-doubling turn sequence, +1 when the 2-adic valuation of n is even or -1 when odd. 1
1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1 (list; graph; refs; listen; history; text; internal format)
OFFSET
1
COMMENTS
a(n)=+1 when the number of low 0 bits of n is even, and a(n)=-1 when odd. This is the "period doubling" sequence A096268 but using +1,-1. See A096268 and its complement A035263 for more. The number of low 0 bits of n is A007814. a(n) is completely multiplicative since A007814(n*m) = A007814(n) + A007814(m).
a(n) is among some completely multiplicative +1,-1 sequences considered by Davis and Knuth for forming curves by unfolding. a(n) is their d(n) at equation 6.4. The curve can be drawn by successively going forward a unit step and turning by a(n)*angle. Their "bending" angle T is equivalent to turns by 180-T degrees. They draw bending angle 90 degrees which is merely 4 unit squares repeatedly traversed; and bending 60 degrees "Fido" and 120 degrees which are bigger and more interesting. Partial sums A068639 are the directions (net total turn) of the segments.
REFERENCES
Chandler Davis and Donald E. Knuth, Number Representations and Dragon Curves -- I and II, Journal of Recreational Mathematics, volume 3, number 2, April 1970, pages 66-81, and number 3, July 1970, pages 133-149. Reprinted in Donald E. Knuth, Selected Papers on Fun and Games, 2010, pages 571-614.
LINKS
Kevin Ryde, Sample Images (and LaTeX source)
FORMULA
a(n) = (-1)^A007814(n) = -(-1)^A065882(n) = 1 - 2*A096268(n-1) = 2*A035263(n) - 1 = A035263(n) - A096268(n-1).
a(n) = A068639(n) - A068639(n-1).
a(A003159) = 1, a(A036554) = -1.
For prime p, a(p) = -1 if p=2 (even), a(p) = 1 if p odd [Davis and Knuth, which together with completely multiplicative defines a(n)].
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/3. - Amiram Eldar, Sep 18 2022
Dirichlet g.f.: zeta(s)*(2^s-1)/(2^s+1). - Amiram Eldar, Jan 03 2023
MATHEMATICA
Array[(-1)^IntegerExponent[#, 2] &, 100] (* Amiram Eldar, Aug 22 2019 *)
PROG
(PARI) a(n) = (-1)^valuation(n, 2);
(UCB Logo) ; a(n), and draw "Fido" of Davis and Knuth
to a :n
output 2*(remainder (bitxor :n :n-1) 3) - 1
end
setheading 90 ; start East
repeat 4095 [ forward 7 ; pixels
left (a repcount) * 120 ] ; or try 60 or 90
(Python)
def A309873(n): return -1 if (~n & n-1).bit_length()&1 else 1 # Chai Wah Wu, Dec 26 2022
CROSSREFS
Partial sums A068639.
Sequence in context: A000012 A216430 A232544 * A162511 A157895 A077008
KEYWORD
mult,sign,easy
AUTHOR
Kevin Ryde, Aug 21 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 18:16 EDT 2024. Contains 371916 sequences. (Running on oeis4.)