[go: up one dir, main page]

login
A108167
Partial sums of the positive integers n according to the rule: if n is square then subtract sqrt(n) else add n.
1
0, -1, 1, 4, 2, 7, 13, 20, 28, 25, 35, 46, 58, 71, 85, 100, 96, 113, 131, 150, 170, 191, 213, 236, 260, 255, 281, 308, 336, 365, 395, 426, 458, 491, 525, 560, 554, 591, 629, 668, 708, 749, 791, 834, 878, 923, 969, 1016, 1064, 1057, 1107, 1158, 1210, 1263, 1317, 1372, 1428, 1485, 1543, 1602, 1662, 1723, 1785, 1848
OFFSET
0,4
LINKS
FORMULA
From Robert Israel, Dec 27 2018: (Start)
a(n) = n(n+1)/2 - m(m+1)(m+2)/3 where m = floor(sqrt(n)).
G.f.: x/(1-x)^3 - (1-x)^(-1)*Sum_{k>=1} (k^2+k)*x^(k^2). (End)
EXAMPLE
0-1=-1,-1+2=1,1+3=4,4-sqrt(4) = 2
MAPLE
f:= proc(n) local m; m:= floor(sqrt(n));
n*(n+1)/2-m*(m+1)*(m+2)/3
end proc:
map(f, [$0..100]); # Robert Israel, Dec 27 2018
MATHEMATICA
f[n_] := If[IntegerQ[Sqrt[n]], -Sqrt[n], n];
f /@ Range[0, 100] // Accumulate (* Jean-François Alcover, Aug 26 2020 *)
PROG
(PARI) g(n) = my(s=0); for(x=0, n, if(issquare(x), s-=sqrtint(x), s+=x); print1(s, ", "))
CROSSREFS
Sequence in context: A356155 A227352 A255140 * A261690 A211941 A050105
KEYWORD
easy,sign
AUTHOR
Cino Hilliard, Jun 13 2005
STATUS
approved