Programmation Avancée en C


fact.c

00001 #include <stdio.h>
00002 
00003 long fact(int n) {
00004     long f = 1;
00005     while(n) {
00006         f *= n;
00007         n--;
00008     }
00009     return f;
00010 }
00011 
00012 int main()
00013 {
00014     printf("fact(4)  = %ld\n",fact(4));
00015     printf("fact(10) = %ld\n",fact(10));
00016     printf("fact(-1) = %ld\n",fact(-1));
00017     return 0;
00018 }