20 operations:
set j = 9
check if j(9) >= 1
set j to 8
check if j(8) >= 1
set j to 7
check if j(7) >= 1
set j to 6
check if j(6) >= 1
set j to 5
check if j(5) >= 1
set j to 4
check if j(4) >= 1
set j to 3
check if j(3) >= 1
set j to 2
check if j(2) >= 1
set j to 1
check if j(1)>=1
set j to 0
check if j(0)>=1
for( j=n ; j>=0 ; j-- )
Ok, you start with two operations:
For all n<0 it stops there.
If n=0, you get an aditional:
For n=1, you get another set of those.
So the number of operations is 2 for n<0 and 2n+4 for n>=0.
These things are not that hard. You just need to think like a computer and carefully note any change to the state (set of variables).