From 64c28f76a241e526e76871b8ed399c5c134c3a88 Mon Sep 17 00:00:00 2001 From: viditkulshreshtha <33063443+viditkulshreshtha@users.noreply.github.com> Date: Thu, 2 Nov 2017 14:51:48 +0530 Subject: [PATCH] added a condition If the user enters the input as 0 (zero) then also the output should be one --- misc/Factorial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/Factorial.c b/misc/Factorial.c index 601ff08f..e8885284 100644 --- a/misc/Factorial.c +++ b/misc/Factorial.c @@ -1,7 +1,7 @@ #include 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; -} \ No newline at end of file +}