RosettaCodeData/Task/Factorial/C++/factorial-1.cpp
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

8 lines
244 B
C++

#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>());
}