Linear Algebra and the C Language/a0iv
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00e.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
int X_factorial(int n)
{
int i = 1;
int x = 1;
if(n==0) return (1);
for(i = 1; i <= n; i++)
x *= i;
return (x);
}
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
int n = 0;
clrscrn();
do{ printf(" %.2d! = %d\n", n, factorial(n));
}while(n++ <12);
printf("\n\n");
stop();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
12! is the maximum correct value for this function: (overfloat)
Screen output example:
00! = 1
01! = 1
02! = 2
03! = 6
04! = 24
05! = 120
06! = 720
07! = 5040
08! = 40320
09! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
Press return to continue.