|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
LINKS
|
|
|
FORMULA
|
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:
|
|
MATHEMATICA
|
f[n_] := If[IntegerQ[Sqrt[n]], -Sqrt[n], n];
|
|
PROG
|
(PARI) g(n) = my(s=0); for(x=0, n, if(issquare(x), s-=sqrtint(x), s+=x); print1(s, ", "))
|
|
CROSSREFS
|
|
|
KEYWORD
|
easy,sign
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|