#if !defined  HAVE_FACTORIAL_H__
#define       HAVE_FACTORIAL_H__
// This file is part of the FXT library.
// Copyright (C) 2010 Joerg Arndt
// License: GNU General Public License version 3 or later,
// see the file COPYING.txt in the main directory.

#include "fxttypes.h"

inline ulong factorial(ulong n)
// Return n!
{
    ulong f = 1;
    while ( n>1 )  { f *= n;  --n; }
    return f;
}
// -------------------------

inline ulong ffactpow(ulong x, ulong n)
// Falling factorial power.
{
    ulong p = 1;
    for (ulong k=0; k<n; ++k)  p *= (x-k);
    return p;
}
// -------------------------

inline ulong rfactpow(ulong x, ulong n)
// Rising factorial power.
{
    ulong p = 1;
    for (ulong k=0; k<n; ++k)  p *= (x+k);
    return p;
}
// -------------------------



#endif  // !defined HAVE_FACTORIAL_H__
