Sigmafy the expression
Mathematica, 17 14 13 bytes
Thanks to Ian Miller for saving 3 bytes.
Thanks to LegionMammal978 for saving 1 byte.
#~NSum~{k,5}&
The input should be an actual expression containing k
, e.g.:
#~NSum~{k,5}&[Sqrt[k]^3+4]
Python 3, 40 37 bytes
3 bytes thanks to Arnauld.
Eval scope tricks \o/
f=lambda s,k=5:k and eval(s)+f(s,k-1)
Try it online!
Uses k**0.5
instead of sqrt(k)
.
JavaScript (ES7), 31 30 bytes
Uses k**0.5
for sqrt(k)
.
f=(e,k=6)=>--k&&f(e,k)+eval(e)
console.log(f("2*k"))
console.log(f("k**0.5"))
console.log(f("k+k/2+k**2"))
console.log(f("k**2"))
Try it online!