/*------------------------------------------------------------------------------* * File Name: ComputeFactorial.c * * Creation: ER, 01/26/05 * * Purpose: Programming Example * * Copyright (c) OriginLab Corp.2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 * * All Rights Reserved * * * * Modification Log: * *------------------------------------------------------------------------------*/ #include #include // needed for nag_gamma function ///////////////////////////////////////////////////////////////////////////////// // This example shows how to call a function from the NAG library to compute // factorial. // // To view documentation on available NAG functions, look up the following section // in the Programming Help File: // Origin C Language Reference -> Global Functions -> NAG Functions // double compute_factorial(int n) { // The NAG Gamma function returns (n-1)! when the argument n is an integer. // The function returns missing value if n is invalid (such as negative number) // or when n > 170. NagError fail; return nag_gamma(n + 1, &fail); } /////////////////////////////////////////////////////////////////////////////////