Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Falling Factorial

#include <boost/math/special_functions/factorials.hpp>
namespace boost{ namespace math{

template <class T>
calculated-result-type falling_factorial(T x, unsigned i);

template <class T, class Policy>
calculated-result-type falling_factorial(T x, unsigned i, const Policy&);

}} // namespaces

Returns the falling factorial of x and i:

falling_factorial(x, i) = x(x-1)(x-2)(x-3)...(x-i+1)

Note that this function is only defined for positive i, hence the unsigned second argument. Argument x can be either positive or negative however.

The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

May return the result of overflow_error if the result is too large to represent in type T.

The return type of these functions is computed using the result type calculation rules: the type of the result is double if T is an integer type, otherwise the type of the result is T.


The accuracy will be the same as the tgamma_delta_ratio function.


The spot tests for the falling factorials use data generated by


Rising and falling factorials are implemented as ratios of gamma functions using tgamma_delta_ratio. Optimisations for small integer arguments are handled internally by that function.