cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A209615 Completely multiplicative with a(p^e) = 1 if p == 1 (mod 4), a(p^e) = (-1)^e otherwise.

Original entry on oeis.org

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
Offset: 1

Views

Author

Michael Somos, Mar 10 2012

Keywords

Comments

Turn sequence of the alternate paperfolding curve. Davis and Knuth define the alternate paperfolding curve by folding a long strip of paper repeatedly in half alternately to the left side or right side, then unfolding it so each crease is 90 degrees (or other angle). a(n) is their d(n) at equation 4.2. Their equation 6.2 (varied to d(2) = -1 as described there) is equivalent to the definition here. The curve is drawn by a unit step forward, turn a(1)*90 degrees left, a unit step forward, turn a(2)*90 degrees left, and so on. - Kevin Ryde, Apr 18 2020

Examples

			G.f. = x - x^2 - x^3 + x^4 + x^5 + x^6 - x^7 - x^8 + x^9 - x^10 - x^11 - x^12 + ...
From _Kevin Ryde_, Apr 18 2020: (Start)
                   ...              alternate
                    | -1           paperfolding
            -1 --->\ \<--- +1         curve
             ^   -1 |      ^
             |      v      |      turns +1 left
  start --> +1     +1 ---> +1        or -1 right
(End)
		

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, CSLI Publications, 2010, pages 571-614.

Crossrefs

Indices of 1: A338692 = A016813 U A343501; indices of -1: A338691 = A004767 U A343500.
Inverse Moebius transform gives A338690.

Programs

  • Mathematica
    A209615[n_] := JacobiSymbol[-1, n]*(-1)^IntegerExponent[n, 2];
    Array[A209615, 100] (* Paolo Xausa, Feb 26 2025 *)
  • PARI
    {a(n) = my(v); if( n==0, 0, v = valuation( n, 2); (-1)^(n/2^v\2 + v))};
    
  • PARI
    {a(n) = if( n!=0, -kronecker( -1, n) * (-1)^if( n!=0, 1 - valuation( n, 2) %2))};
    
  • PARI
    {a(n) = my(A, p, e, f); sign(n) * if( n==0, 0, A = factor(abs(n)); prod( k=1, matsize(A)[1], [p, e] = A[k, ]; (-1)^(e * (p%4 != 1))) )};
    
  • Python
    def A209615(n): return -1 if ((n>>(m:=(~n&n-1).bit_length()))+1>>1)+m&1^1 else 1 # Chai Wah Wu, Feb 25 2025

Formula

G.f.: Sum_{k>=0} (-1)^k * x^(2^k) / (1 + x^(2^(k+1))).
G.f. A(x) satisfies A(x) + A(x^2) = x / (1 + x^2).
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = (v + w) - (u + v)^2 * (1 + 2*(v + w)).
If p is prime then a(p) = 1 if and only if p is in A002144.
a(4*n + 1) = 1, a(4*n + 3) = -1. a(2*n) = a(3*n) = a(-n) = -a(n).
a(n) = -(-1)^A106665(n-1) unless n=0.
a(2n) = -a(n), a(2n+1) = (-1)^n. [Davis and Knuth equation 4.2] - Kevin Ryde, Apr 18 2020
From Jianing Song, Apr 24 2021: (Start)
a(n) = 1 <=> A003324(n) = 1 or 4, a(n) = -1 <=> A003324(n) = 2 or 3. In other words, a(n) = Legendre(A003324(n), 5) == A003324(n)^2 (mod 5).
a(n) = A034947(n) * (-1)^(v2(n)), where v2(n) = A007814(n) is the 2-adic valuation of n.
Dirichlet g.f.: beta(s)/(1 + 2^(-s)). (End)