, :
1 2 3 4 5 6 7 8 9 10
, "" :
0 1 2 3 4
9 8 7 6 5
, , 9 (N-1), 5 (N/2) . , N N/2 , (N-1). , , (N/2) (N-1), ( ) N (N-1)/2.
, "" , . "0", , . , N = 9 N = 10. :
1 2 3 4
8 7 6 5
This gives us (N-1) / 2 columns (9-1 = 8, 8/2 = 4), each of which adds up to N, so the sum will be N * (N-1) / 2. Despite the fact that we came to this in a slightly different way, this is an exact match for the formula above when N is equal. Again, it seems pretty obvious that this will remain true regardless of the number of columns used (i.e. the total number of iterations).
For any N (odd or even), the sum of numbers from 0 to N-1 is N * (N-1) / 2.
source
share