From 69ed4f665158fb376c62e3544814d807561744e0 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 01:31:07 +0100 Subject: [PATCH] added termination condition in function --- src/fakultaet/fakultaet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fakultaet/fakultaet.c b/src/fakultaet/fakultaet.c index 93273f6..d10c0a0 100644 --- a/src/fakultaet/fakultaet.c +++ b/src/fakultaet/fakultaet.c @@ -1,6 +1,11 @@ #include int fakultaet(int n) { + if (n < 0) { + printf("Fakultaet kann nicht für negative Zahlen berechnet werden!\n"); + return -1; + } + if (n == 0 || n == 1) return 1;