/* facf.c
*
* Factorial function
*
*
*
* SYNOPSIS :
*
* float y , facf ( ) ;
* int i ;
*
* y = facf ( i ) ;
*
*
*
* DESCRIPTION :
*
* Returns factorial of i = 1 * 2 * 3 * . . . * i .
* fac ( 0 ) = 1 . 0 .
*
* Due to machine arithmetic bounds the largest value of
* i accepted is 33 in single precision arithmetic .
* Greater values , or negative ones ,
* produce an error message and return MAXNUM .
*
*
*
* ACCURACY :
*
* For i < 34 the values are simply tabulated , and have
* full machine accuracy .
*
*/
/*
Cephes Math Library Release 2 . 0 : April , 1987
Copyright 1984 , 1987 by Stephen L . Moshier
Direct inquiries to 30 Frost Street , Cambridge , MA 02140
*/
#include "mconf.h"
/* Factorials of integers from 0 through 33 */
static double factbl[] = {
1 .00000000000000000000 E0,
1 .00000000000000000000 E0,
2 .00000000000000000000 E0,
6 .00000000000000000000 E0,
2 .40000000000000000000 E1,
1 .20000000000000000000 E2,
7 .20000000000000000000 E2,
5 .04000000000000000000 E3,
4 .03200000000000000000 E4,
3 .62880000000000000000 E5,
3 .62880000000000000000 E6,
3 .99168000000000000000 E7,
4 .79001600000000000000 E8,
6 .22702080000000000000 E9,
8 .71782912000000000000 E10,
1 .30767436800000000000 E12,
2 .09227898880000000000 E13,
3 .55687428096000000000 E14,
6 .40237370572800000000 E15,
1 .21645100408832000000 E17,
2 .43290200817664000000 E18,
5 .10909421717094400000 E19,
1 .12400072777760768000 E21,
2 .58520167388849766400 E22,
6 .20448401733239439360 E23,
1 .55112100433309859840 E25,
4 .03291461126605635584 E26,
1 .0888869450418352160768 E28,
3 .04888344611713860501504 E29,
8 .841761993739701954543616 E30,
2 .6525285981219105863630848 E32,
8 .22283865417792281772556288 E33,
2 .6313083693369353016721801216 E35,
8 .68331761881188649551819440128 E36
};
#define MAXFACF 33
extern double MAXNUMF;
#ifdef ANSIC
float facf( int i )
#else
float facf(i)
int i;
#endif
{
if ( i < 0 )
{
mtherr( "facf" , SING );
return ( MAXNUMF );
}
if ( i > MAXFACF )
{
mtherr( "facf" , OVERFLOW );
return ( MAXNUMF );
}
/* Get answer from table for small i. */
return ( factbl[i] );
}
Messung V0.5 in Prozent C=97 H=100 G=98
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-17)
¤
*© Formatika GbR, Deutschland