login
A268173
a(n) = Sum_{k=0..n} (-1)^k*floor(sqrt(k)).
4
0, -1, 0, -1, 1, -1, 1, -1, 1, -2, 1, -2, 1, -2, 1, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -3, 2, -3, 2, -3, 2, -3, 2, -3, 2, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, 3, -4, 3, -4, 3, -4, 3, -4, 3, -4, 3, -4, 3, -4, 3, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4
OFFSET
0,10
LINKS
FORMULA
a(n) = floor(sqrt(n))*(-1)^n/2 - ((-1)^(floor(sqrt(n))+1)+1)/4.
a(n) = (-1)^n * Sum_{i=1..ceiling(n/2)} c(n+2-2*i), where c is the square characteristic (A010052). - Wesley Ivan Hurt, Nov 26 2020
From Ridouane Oudra, Jan 21 2024: (Start)
a(n) = (-1)^n*floor((sqrt(n) + (n mod 2))/2);
a(2*n) = floor(sqrt(n/2));
a(2*n+1) = -floor(sqrt((n+1)/2) + 1/2). (End)
EXAMPLE
a(5) = -1 = floor(sqrt(0)) - floor(sqrt(1)) + floor(sqrt(2)) - floor(sqrt(3)) + floor(sqrt(4)) - floor(sqrt(5)).
MAPLE
seq(add((-1)^k*floor(sqrt(k)), k=0..n), n=0..80); # Ridouane Oudra, Jan 21 2024
MATHEMATICA
Table[Sum[(-1)^k Floor[Sqrt@ k], {k, 0, n}], {n, 0, 50}] (* Michael De Vlieger, Mar 15 2016 *)
PROG
(PARI) a(n) = sum(k=0, n, (-1)^k*sqrtint(k)); \\ Michel Marcus, Jan 28 2016
(PARI) a(n) = sqrtint(n)*(-1)^n/2-((-1)^(sqrtint(n)+1)+1)/4; \\ John M. Campbell, Mar 15 2016
KEYWORD
sign,easy
AUTHOR
John M. Campbell, Jan 28 2016
EXTENSIONS
Terms a(55) and beyond from Andrew Howroyd, Mar 02 2020
STATUS
approved