for (int i=1;i<=n;i++){
for (int j=i;j<=n;j++){
do_something
}
}
I need to calculate how many times the "do something" step happens.
I started like so:
$\sum _{i=1}^n\:\sum _{j=i}^n\:1$
I got stuck here trying to open the inner sum. I know that the algorithm is O(n^2) but I find it hard to prove it.