factrl.c
来自「< C语言数值算法程序大全>>配套程序」· C语言 代码 · 共 19 行
C
19 行
#include <math.h>
float factrl(int n)
{
float gammln(float xx);
void nrerror(char error_text[]);
static int ntop=4;
static float a[33]={1.0,1.0,2.0,6.0,24.0};
int j;
if (n < 0) nrerror("Negative factorial in routine factrl");
if (n > 32) return exp(gammln(n+1.0));
while (ntop<n) {
j=ntop++;
a[ntop]=a[j]*ntop;
}
return a[n];
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?