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.

A140670 a(n) = 1 if n is odd; otherwise, a(n) = 2^k - 1 where 2^k is the largest power of 2 that divides n.

Original entry on oeis.org

1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 15, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 31, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 15, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 63, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 15, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 3, 1, 1, 1, 31, 1, 1, 1, 3, 1, 1
Offset: 1

Views

Author

Michael Somos, May 21 2008

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := If[OddQ[n], 1, 2^IntegerExponent[n, 2] - 1]; Array[a, 100] (* Amiram Eldar, Oct 22 2022 *)
  • PARI
    {a(n) = if(n==0, 0, if(n%2, 1, 2^valuation(n, 2) - 1))}
    
  • Python
    def A140670(n): return max(1,(n&-n)-1) # Chai Wah Wu, Jul 08 2022

Formula

a(n) is multiplicative with a(2^e) = 2^e - 1 if e > 0, a(p^e) = 1 if p > 2.
a(2*n + 1) = 1. a(-n) = a(n). a(2*n) = 2 * a(n) + (-1)^n unless n=0.
Dirichlet g.f.: zeta(s)*(1+2^(1-2s)-2^(1-s))/(1-2^(1-s)). - R. J. Mathar, Feb 07 2011
a(n) = (2*A160467(n))-1. - Antti Karttunen, Nov 18 2017
Sum_{k=1..n} a(k) ~ (1/(2*log(2))) * (n*log(n) + (gamma + log(2)/2 - 1) * n), where gamma is Euler's constant (A001620). - Amiram Eldar, Oct 22 2022
a(n) = A006519(n) - A059841(n). - Ridouane Oudra, Jul 30 2025