RosettaCodeData/Task/Factorial/C++/factorial-1.cpp

9 lines
244 B
C++
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
#include <boost/iterator/counting_iterator.hpp>
#include <algorithm>
int factorial(int n)
{
// last is one-past-end
return std::accumulate(boost::counting_iterator<int>(1), boost::counting_iterator<int>(n+1), 1, std::multiplies<int>());
}