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!)
A059851 a(n) = n - floor(n/2) + floor(n/3) - floor(n/4) + ... (this is a finite sum). 25

%I #34 Oct 23 2023 17:58:14

%S 0,1,1,3,2,4,4,6,4,7,7,9,7,9,9,13,10,12,12,14,12,16,16,18,14,17,17,21,

%T 19,21,21,23,19,23,23,27,24,26,26,30,26,28,28,30,28,34,34,36,30,33,33,

%U 37,35,37,37,41,37,41,41,43,39,41,41,47,42,46,46,48,46,50,50,52,46,48,48

%N a(n) = n - floor(n/2) + floor(n/3) - floor(n/4) + ... (this is a finite sum).

%C As n goes to infinity we have the asymptotic formula: a(n) ~ n * log(2).

%H T. D. Noe, <a href="/A059851/b059851.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = A006218(n)-2*A006218(floor(n/2)). G.f.: 1/(1-x)*Sum_{n>=1} x^n/(1+x^n). Partial sums of A048272. - _Vladeta Jovovic_, Oct 15 2002

%F a(n) = Sum_{n/2 < k < =n} d(k) - Sum_{1 < =k <= n/2} d(k), where d(k) = A000005(k). Also, a(n) = number of terms among {floor(n/k)}, 1<=k<=n, that are odd. - _Leroy Quet_, Jan 19 2006

%F From _Ridouane Oudra_, Aug 15 2019: (Start)

%F a(n) = Sum_{k=1..n} (floor(n/k) mod 2)

%F a(n) = (n/2) + (1/2)*A271860(n)

%F a(n) = Sum_{k=1..n} round(n/(2*k)) - floor(n/(2*k)), where round(1/2)=1. (End)

%e a(5) = 4 because floor(5) - floor(5/2) + floor(5/3) - floor(5/4) + floor(5/5) - floor(5/6) + ... = 5 - 2 + 1 - 1 + 1 - 0 + 0 - 0 + ... = 4.

%p for n from 0 to 200 do printf(`%d,`, sum((-1)^(i+1)*floor(n/i), i=1..n)) od:

%p { for (n=0, 10000, s=1; d=2; a=n; while ((f=floor(n/d)) > 0, a-=s*f; s=-s; d++); write("b059851.txt", n, " ", a); ) } # _Harry J. Smith_, Jun 29 2009

%t f[list_, i_] := list[[i]]; nn = 200; a = Table[1, {n, 1, nn}]; b =

%t Table[If[OddQ[n], 1, -1], {n, 1, nn}];Table[DirichletConvolve[f[a, n], f[b, n], n, m], {m, 1, nn}] // Accumulate (* _Geoffrey Critzer_, Mar 29 2015 *)

%t Table[Sum[Floor[n/k] - 2*Floor[n/(2*k)], {k, 1, n}], {n, 0, 100}] (* _Vaclav Kotesovec_, Dec 23 2020 *)

%o (PARI) { for (n=0, 10000, s=1; d=2; a=n; while ((f=floor(n/d)) > 0, a-=s*f; s=-s; d++); write("b059851.txt", n, " ", a); ) } \\ _Harry J. Smith_, Jun 29 2009

%o (Python)

%o from math import isqrt

%o def A059851(n): return ((t:=isqrt(m:=n>>1))**2<<1)-(s:=isqrt(n))**2+(sum(n//k for k in range(1,s+1))-(sum(m//k for k in range(1,t+1))<<1)<<1) # _Chai Wah Wu_, Oct 23 2023

%Y Cf. A075997.

%Y Partial sums of A048272.

%K nonn,easy

%O 0,4

%A Avi Peretz (njk(AT)netvision.net.il), Feb 27 2001

%E More terms from _James A. Sellers_ and Larry Reeves (larryr(AT)acm.org), Feb 27 2001

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 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)