cppreference.com > C++ Algorithms > accumulate
accumulate
Syntax:
  #include <algorithm>
  TYPE accumulate( iterator start, iterator end, TYPE val );
  TYPE accumulate( iterator start, iterator end, TYPE val, BinaryFunction f );

The accummulate() function computes the sum of val and all of the elements in the range [start,end).

If the binary function f if specified, it is used instead of the + operator to perform the summation.

accumulate() runs in linear time.