A good friend would tell you that there is a closed-form solution for outsideLoop
. In other words, there’s no need to use a for
loop at all, which saves computation time.
outsideLoop = n * (n + 1) / 2
, where, in your case, n
is 10.
This comes from the sum of an arithmetic progression.