Add a Factorial Algorithm

This commit is contained in:
Luiz Carlos Aguiar 2017-07-04 17:17:22 -03:00
parent fd8d20e907
commit 06f872bb8b

20
fat.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
int fat(int number){
if (number == 1)
return 1;
else
return number*fat(number-1);
}
int main(){
int number;
//Asks the factorial of the number n
printf("Number: ");
scanf("%d", &number);
printf("%d\n", fat(number));
return 0;
}