From 1b96219fd5e6cff2ebd8737f99aa3d21a826cf26 Mon Sep 17 00:00:00 2001 From: fdai7848 Date: Tue, 30 Jan 2024 09:15:31 +0100 Subject: [PATCH] add a temporary faculty function --- src/exponent.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/exponent.c b/src/exponent.c index 3f4895a..e82de4e 100644 --- a/src/exponent.c +++ b/src/exponent.c @@ -1,4 +1,5 @@ #include +#include #include "exponent.h" @@ -24,4 +25,17 @@ double expIN(double e, double num){ } } return 0; -} \ No newline at end of file +} + +unsigned long long fac(int x){ + unsigned long long prod = 1; + if(x==0) return 1; + for (int i = 1; i <= x; i++){ + if (prod > ULLONG_MAX / i){ + break; + } + prod*=i; + } + return prod; +} +