From c94eefc9126c724caad3b2d9d23fc560f26bad71 Mon Sep 17 00:00:00 2001 From: Ulriche Nguefack Date: Wed, 7 Feb 2024 14:42:24 +0100 Subject: [PATCH] refactoring: factorial --- src/main/c/Calculator/calculator.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 1ddf5fe..8d4cdc8 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -121,6 +121,13 @@ double getDoubleInput(const char *message) { scanf("%lf", &input); return input; } +double factorial(double num) { + if (num == 0) { + return 1; + } else { + return num * factorial(num - 1); + } +} int getIntInput(const char *message) { int input;