Current location - Training Enrollment Network - Mathematics courses - Mathematical representation of total number
Mathematical representation of total number
Suppose this column number is $a_ 1, a_2, \ldots, a_n$, where $n$ is the length of this column number.

We can use a variable $sum$ to record the sum of negative numbers under each positive number, and another variable $total$ to record the sum of all negative numbers under all positive numbers.

The specific implementation method is as follows:

1. Initially, $sum=0$, $total=0$.

2. Traverse the column number from left to right. For each $a_i$ number:

A. If $a_i$ is a positive number, add $sum$ to $total$ and set $sum$ to 0.

B. If $a_i$ is negative, add $a_i$ to $sum$.

3. After traversing the whole series, if the last number is positive, add $sum$ to $total$.

In this way, the value of $total$ is the sum of all negative numbers under positive numbers.

The mathematical formula is as follows:

$ $ total = \sum_{i= 1}^{n}[a _ I & gt; 0](\sum_{j=i+ 1}^{n}[a_j<; 0]a_j)$$

Where $ [a _ i >; 0]$ is an index function with a value of 1 or 0, which means that when $ a _ i >; 0$ is 1, otherwise it is 0; $[a _ j & lt; 0]$ is also a indicator function, which means that when $ a _ j