Using std::accumulate and std::iota to make code more compact.