, .
j , . .
, , , 1 + 2 + 3 + ... + i - 1 + i . , i * (i + 1) / 2. (i^2 + i) / 2
, , ((1^2+1) + (2^2+2) + ... (n^2+n))/2 times.
.
Although this problem is unsolvable in general - if you knew how many times each line of code in the program was executed, you would solve the problem with stopping.
source
share