I'm sorry this looks a lot like a do my homework question, but it's something I came across at work and thought I'd ask you guys (and my math is rusty). In Pascal it looks like this
l:=n; for i:=1 to n do inc(l,(i*((i div 2)+1)) div 2);
If I have a go at putting it in formula I guess it looks like this:
Is there a way to calculate it in a single Pascal expression without iteration?
Caveat here is ofcourse that
div rounds the result
down towards zero, but when using a positive $n$ the result should be on or closely above the value I'm after, and in context it's needed as a guard value to keep an eye on the maximum number of iterations of another part of the program, so perhaps it would be permissable to ignore the rounding.