TheAlgorithms-C/misc/Factorial.c

21 lines
284 B
C
Raw Normal View History

2017-07-04 23:17:22 +03:00
#include <stdio.h>
int fat(int number){
if (number == 1 || number == 0)
2017-07-04 23:17:22 +03:00
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;
}