added a condition

If the user enters the input as 0 (zero) then also the output should be one
This commit is contained in:
viditkulshreshtha 2017-11-02 14:51:48 +05:30 committed by GitHub
parent 03a0e01950
commit 64c28f76a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
#include <stdio.h>
int fat(int number){
if (number == 1)
if (number == 1 || number == 0)
return 1;
else
return number*fat(number-1);
@ -17,4 +17,4 @@ int main(){
printf("%d\n", fat(number));
return 0;
}
}