A Very Big Sum

  • + 0 comments

    Also possible with single l:

    return accumulate(ar.begin(), ar.end(), 0L);
    

    From https://en.cppreference.com/w/cpp/algorithm/accumulate:

    Common mistakes If left to type inference, op operates on values of the same type as init which can result in unwanted casting of the iterator elements. For example, std::accumulate(v.begin(), v.end(), 0) likely does not give the result one wishes for when v is std::vector.