For the following pseudocode, express what is returned as a function of n, and find the big-O notation for the worst-case running time.
I'm thinking O(n3) because it is three nested for loops, but I'm not really sure how to go about this more rigorously.
function pesky(n)
r <- 0
for i <- 1 to n do
for j <- 1 to i do
for k <- j to i+j do
r <- r + 1
end for
end for
end for
return r