From b201c968d27ac2230d7b4d245a9f3608c162e285 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:43:18 +0100 Subject: [PATCH] Summen Funktion implementiert --- src/ProduktSumme.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 0899097..3b8be64 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -30,4 +30,18 @@ int berechneProdukt(int start, int ende) { } } return produkt; +} + +int berechneSumme(int start, int ende) { + + if (start > ende) { + return 0; + } + + int summe = 0; + for (int i = start; i <= ende; i++) { + summe += i; + } + + return summe; } \ No newline at end of file