OFFSET
2,2
COMMENTS
"Nearest integer to" rounds down rather than up when given an exact half-integer.
Can also be described as Sum_{k=1..n-1} { nearest integer to (n-k)/k }. - Jackson Xier, Oct 04 2011
REFERENCES
Marc LeBrun, personal communication.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
G. C. Greubel, Table of n, a(n) for n = 2..2500
Marc LeBrun, Email to N. J. A. Sloane, Jul 1991
FORMULA
Clearly a(n) = n log n + O(n); a better estimate is surely possible.
EXAMPLE
Row sums of the triangle with entries floor((2n-1)/(2k+1)):
0 : 0;
1 : 1, 0;
2 : 1, 1, 0;
4 : 2, 1, 1, 0;
6 : 3, 1, 1, 1, 0;
8 : 3, 2, 1, 1, 1, 0;
10 : 4, 2, 1, 1, 1, 1, 0;
14 : 5, 3, 2, 1, 1, 1, 1, 0;
15 : 5, 3, 2, 1, 1, 1, 1, 1, 0;
18 : 6, 3, 2, 2, 1, 1, 1, 1, 1, 0;
22 : 7, 4, 3, 2, 1, 1, 1, 1, 1, 1, 0;
...;
MAPLE
N:=proc(x) local t1; t1:=floor(x); if x-t1 = 1/2 then t1 else floor(x+1/2); fi; end;
f:=n->add(N((n-k)/k), k=1..n-1);
[seq(f(n), n=1..120)]; # N. J. A. Sloane, Oct 02 2011
MATHEMATICA
a[n_]:= Sum[Floor[(2n-1)/(2k+1)], {k, n}]; (* Jackson Xier, Oct 04 2011 *)
PROG
(PARI) a(n)=sum(k=1, n, (2*n-1)\(2*k+1)) \\ Charles R Greathouse IV, Oct 04 2011
(Magma)
A006586:= func< n | (&+[Floor((2*n-1)/(2*k+1)): k in [1..n]]) >;
[A006586(n): n in [2..100]]; // G. C. Greubel, Aug 27 2025
(SageMath)
def A006586(n): return sum((2*n-1)//(2*k+1) for k in range(1, n+1))
print([A006586(n) for n in range(2, 101)]) # G. C. Greubel, Aug 27 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
More terms from Gareth McCaughan, Jun 10 2004
STATUS
approved
