login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A075997
a(n) = [n/2] - [n/3] + [n/4] - [n/5] + [n/6] - ..., where [n/k] = floor(n/k).
4
0, 0, 1, 0, 2, 1, 2, 1, 4, 2, 3, 2, 5, 4, 5, 2, 6, 5, 6, 5, 8, 5, 6, 5, 10, 8, 9, 6, 9, 8, 9, 8, 13, 10, 11, 8, 12, 11, 12, 9, 14, 13, 14, 13, 16, 11, 12, 11, 18, 16, 17, 14, 17, 16, 17, 14, 19, 16, 17, 16, 21, 20, 21, 16, 22, 19, 20, 19, 22, 19, 20, 19, 26, 25, 26, 21, 24, 21, 22, 21
OFFSET
0,5
COMMENTS
a(n) is the number of terms among {floor(n/k)}, 1<=k<=n, which are even. - Leroy Quet, Jan 19 2006
FORMULA
a(n) = n - A059851(n).
a(n) = n - A006218(n) + 2*A006218(floor(n/2)). - Vladeta Jovovic, Oct 02 2002
a(n) = n - Sum_{n/2<k<=n} d(k) + Sum_{1<=k<=n/2} d(k), where d(k) = A000005(k). - Leroy Quet, Jan 19 2006
G.f.: ( Sum_{i>0} x^(2*i)/(1+x^i) )/(1-x). - Vladeta Jovovic, Apr 24 2006
a(n) = Sum_{i=1..n} floor(n/(2*i)) - floor((n-i)/(2*i)). - Wesley Ivan Hurt, Jan 30 2016
Conjecture: Let f(a,b)=1, if (a+b) mod |a-b| != (a mod |a-b|)+(b mod |a-b|), and 0 otherwise. a(n) = Sum_{k=1..n-1} f(n+k,n-k). - Benedict W. J. Irwin, Sep 23 2016
a(n) = Sum_{k=1..n} (floor((n-i)/i) mod 2 ). - Wesley Ivan Hurt, Dec 20 2020
EXAMPLE
a(6) = [6/2]-[6/3]+[6/4]-[6/5]+[6/6]-[6/7]+... = 3-2+1-1+1-0+... = 2.
MAPLE
A075997:=n->add(floor(n/(2*i))-floor((n-i)/(2*i)), i=1..n): seq(A075997(n), n=0..100); # Wesley Ivan Hurt, Jan 30 2016
MATHEMATICA
Table[Sum[Floor[n/(2 i)] - Floor[(n - i)/(2 i)], {i, n}], {n, 0, 100}] (* Wesley Ivan Hurt, Jan 30 2016 *)
PROG
(PARI) a(n) = sum(k=2, n, (-1)^k*(n\k)); \\ Michel Marcus, Dec 20 2020
(Python)
from math import isqrt
def A075997(n): return n+(s:=isqrt(n))**2-((t:=isqrt(m:=n>>1))**2<<1)-(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Clark Kimberling, Sep 28 2002
STATUS
approved