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!)
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. 5

%I #20 Oct 22 2022 08:06:16

%S 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,

%T 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,

%U 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

%N 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.

%H Antti Karttunen, <a href="/A140670/b140670.txt">Table of n, a(n) for n = 1..16384</a>

%F a(n) is multiplicative with a(2^e) = 2^e - 1 if e > 0, a(p^e) = 1 if p > 2.

%F a(2*n + 1) = 1. a(-n) = a(n). a(2*n) = 2 * a(n) + (-1)^n unless n=0.

%F Dirichlet g.f.: zeta(s)*(1+2^(1-2s)-2^(1-s))/(1-2^(1-s)). - _R. J. Mathar_, Feb 07 2011

%F a(n) = (2*A160467(n))-1. - _Antti Karttunen_, Nov 18 2017

%F 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

%t a[n_] := If[OddQ[n], 1, 2^IntegerExponent[n, 2] - 1]; Array[a, 100] (* _Amiram Eldar_, Oct 22 2022 *)

%o (PARI) {a(n) = if(n==0, 0, if(n%2, 1, 2^valuation(n, 2) - 1))}

%o (Python)

%o def A140670(n): return max(1,(n&-n)-1) # _Chai Wah Wu_, Jul 08 2022

%Y Cf. A001620, A006519, A135481, A160467.

%K nonn,mult

%O 1,4

%A _Michael Somos_, May 21 2008

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 25 06:14 EDT 2024. Contains 371964 sequences. (Running on oeis4.)