Suppose a numerical sequence has period from index , and let . For with , split the required sum into complete periods and a tail of length . Every complete period contributes , proving the formula in the title. Precomputed prefix sums of one period make the tail lookup constant time. If this periodic sequence consists of the first differences of another sequence, the same formula extrapolates that original sequence by adding the initial value at .
Articles by others on the same topic
There are currently no matching articles.