You declared k
, but not n
, so you're getting the default n
which is a function:
sage: n
<function sage.misc.functional.numerical_approx>
Do the same thing you did for k
:
sage: k, n = var("k n")
sage: sum(k^2, k, 1, n)
1/3*n^3 + 1/2*n^2 + 1/6*n