From ef3f1f8c3deec07fb024885deb0322c0b2e02561 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:41:32 +0100 Subject: [PATCH 01/19] added gaussscheSummenformel --- src/gaussscheSummenformel/gaussscheSummenformel.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/gaussscheSummenformel/gaussscheSummenformel.c diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c new file mode 100644 index 0000000..e69de29 From 60b7209fadf2089509e9ba2cf3bb62cf76bdcfd1 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:47:11 +0100 Subject: [PATCH 02/19] added header and function --- src/gaussscheSummenformel/gaussscheSummenformel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index e69de29..e83b6fd 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -0,0 +1,6 @@ +#include + +int gaussscheSummenformel(int n) { + + +} \ No newline at end of file From 5593cba142fc8b5f1114b5f34fd1ab60070d8879 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:51:11 +0100 Subject: [PATCH 03/19] adding to function --- src/gaussscheSummenformel/gaussscheSummenformel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index e83b6fd..dbb3785 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -1,6 +1,7 @@ #include int gaussscheSummenformel(int n) { + int result = n * (n + 1); } \ No newline at end of file From 2cc800bc6db6ecc9d484552b9e73444cae2479e2 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:53:11 +0100 Subject: [PATCH 04/19] finished function --- src/gaussscheSummenformel/gaussscheSummenformel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index dbb3785..57dd893 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -2,6 +2,6 @@ int gaussscheSummenformel(int n) { int result = n * (n + 1); - - + result = result / 2; + return result; } \ No newline at end of file From 3e4ef9b2f0ee29971d635a3bb0ad49ff6cca912c Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:56:02 +0100 Subject: [PATCH 05/19] added gaussscheSummenformel.h --- src/gaussscheSummenformel/gaussscheSummenformel.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/gaussscheSummenformel/gaussscheSummenformel.h diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.h b/src/gaussscheSummenformel/gaussscheSummenformel.h new file mode 100644 index 0000000..e69de29 From debaec937ca806f3ae3bfaeee96c6b326b7422e1 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 19:59:18 +0100 Subject: [PATCH 06/19] updated gausscheSummenformel.h --- src/gaussscheSummenformel/gaussscheSummenformel.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.h b/src/gaussscheSummenformel/gaussscheSummenformel.h index e69de29..4e393ee 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.h +++ b/src/gaussscheSummenformel/gaussscheSummenformel.h @@ -0,0 +1,6 @@ +#ifndef GAUSSSCHESUMMENFORMEL_H +#define GAUSSSCHESUMMENFORMEL_H + +int gaussscheSummenformel(int n); + +#endif \ No newline at end of file From 25d53ecbff264b0ffb18d668c7bcd68fb0aeab57 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:01:36 +0100 Subject: [PATCH 07/19] added main --- src/gaussscheSummenformel/main.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/gaussscheSummenformel/main.c diff --git a/src/gaussscheSummenformel/main.c b/src/gaussscheSummenformel/main.c new file mode 100644 index 0000000..e69de29 From fa20fd0eded0ea3c3b81769f20bc58762d2fb383 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:04:51 +0100 Subject: [PATCH 08/19] added headers --- src/gaussscheSummenformel/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gaussscheSummenformel/main.c b/src/gaussscheSummenformel/main.c index e69de29..91ef02b 100644 --- a/src/gaussscheSummenformel/main.c +++ b/src/gaussscheSummenformel/main.c @@ -0,0 +1,9 @@ +#include "gaussscheSummenformel.h" +#include "../userinput.h" +#include + +int main() { + + + +} \ No newline at end of file From d09887870a50f8b99803d5a52d32f5c00230e9a5 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:14:33 +0100 Subject: [PATCH 09/19] added user input --- src/gaussscheSummenformel/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gaussscheSummenformel/main.c b/src/gaussscheSummenformel/main.c index 91ef02b..b435967 100644 --- a/src/gaussscheSummenformel/main.c +++ b/src/gaussscheSummenformel/main.c @@ -3,7 +3,9 @@ #include int main() { + int minInput = 0; + int n = usergetd("Bitte die Anzahl der natuerlichen Zahlen angeben: ", minInput, NULL); } \ No newline at end of file From 5ef1b842069d94057114f8daad3a9e4b1fb7a2ac Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:20:51 +0100 Subject: [PATCH 10/19] finished function in main --- src/gaussscheSummenformel/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gaussscheSummenformel/main.c b/src/gaussscheSummenformel/main.c index b435967..7f4236c 100644 --- a/src/gaussscheSummenformel/main.c +++ b/src/gaussscheSummenformel/main.c @@ -7,5 +7,8 @@ int main() { int n = usergetd("Bitte die Anzahl der natuerlichen Zahlen angeben: ", minInput, NULL); + int erg = gaussscheSummenformel(n); + printf("Die Summe der ersten %d natuerlichen Zahlen ist: %d\n", n, erg); + return 0; } \ No newline at end of file From 1dcd39cc91e9153c7e77d4d3c2db0054e561ef63 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:24:20 +0100 Subject: [PATCH 11/19] refactoring: comments in main --- src/gaussscheSummenformel/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gaussscheSummenformel/main.c b/src/gaussscheSummenformel/main.c index 7f4236c..b6c2b72 100644 --- a/src/gaussscheSummenformel/main.c +++ b/src/gaussscheSummenformel/main.c @@ -5,8 +5,10 @@ int main() { int minInput = 0; + // Benutzereingabe für die Anzahl der natürlichen Zahlen int n = usergetd("Bitte die Anzahl der natuerlichen Zahlen angeben: ", minInput, NULL); + // berechnung der Formel, dann Ausgabe des Ergebnisses int erg = gaussscheSummenformel(n); printf("Die Summe der ersten %d natuerlichen Zahlen ist: %d\n", n, erg); From fe04e06a0802c7474b1b028538da7d19e382f869 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:29:01 +0100 Subject: [PATCH 12/19] refactoring: structure --- src/gaussscheSummenformel/gaussscheSummenformel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index 57dd893..986ae81 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -1,7 +1,10 @@ #include int gaussscheSummenformel(int n) { + int result = n * (n + 1); + result = result / 2; + return result; } \ No newline at end of file From 50c7ea0623a252a91e1b35fae69b27c751bf301f Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:35:19 +0100 Subject: [PATCH 13/19] added test_gaussscheSummenformel.c --- test/gaussscheSummenformel/test_gaussscheSummenformel.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/gaussscheSummenformel/test_gaussscheSummenformel.c diff --git a/test/gaussscheSummenformel/test_gaussscheSummenformel.c b/test/gaussscheSummenformel/test_gaussscheSummenformel.c new file mode 100644 index 0000000..e69de29 From 2b274a87933800294e22a082a911bccdef35b75d Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:42:18 +0100 Subject: [PATCH 14/19] included header --- test/gaussscheSummenformel/test_gaussscheSummenformel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/gaussscheSummenformel/test_gaussscheSummenformel.c b/test/gaussscheSummenformel/test_gaussscheSummenformel.c index e69de29..15e88f8 100644 --- a/test/gaussscheSummenformel/test_gaussscheSummenformel.c +++ b/test/gaussscheSummenformel/test_gaussscheSummenformel.c @@ -0,0 +1,6 @@ +#include "unity.h" +#include "gaussscheSummenformel.h" + +void setUP(){} +void tearDown(){} + From 4115cbf087d6d097ae9985ae69a0a197e342b9a4 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 20:54:02 +0100 Subject: [PATCH 15/19] added test case 1 --- test/gaussscheSummenformel/test_gaussscheSummenformel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/gaussscheSummenformel/test_gaussscheSummenformel.c b/test/gaussscheSummenformel/test_gaussscheSummenformel.c index 15e88f8..2395139 100644 --- a/test/gaussscheSummenformel/test_gaussscheSummenformel.c +++ b/test/gaussscheSummenformel/test_gaussscheSummenformel.c @@ -4,3 +4,7 @@ void setUP(){} void tearDown(){} +void test_gaussscheSummenformel() { + TEST_ASSERT_EQUAL_INT(1, gaussscheSummenformel(1)); + +} \ No newline at end of file From d204caaab3a23b19c5876528d71072b0bac99724 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 21:26:44 +0100 Subject: [PATCH 16/19] added more tests --- test/gaussscheSummenformel/test_gaussscheSummenformel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/gaussscheSummenformel/test_gaussscheSummenformel.c b/test/gaussscheSummenformel/test_gaussscheSummenformel.c index 2395139..99a9219 100644 --- a/test/gaussscheSummenformel/test_gaussscheSummenformel.c +++ b/test/gaussscheSummenformel/test_gaussscheSummenformel.c @@ -5,6 +5,10 @@ void setUP(){} void tearDown(){} void test_gaussscheSummenformel() { + TEST_ASSERT_EQUAL_INT(1, gaussscheSummenformel(1)); + TEST_ASSERT_EQUAL_INT(15, gaussscheSummenformel(5)); + TEST_ASSERT_EQUAL_INT(55, gaussscheSummenformel(10)); + TEST_ASSERT_EQUAL_INT(5050, gaussscheSummenformel(100)); } \ No newline at end of file From 549f88e0320d05ca91d522771829ec6d949b7b34 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 21:30:15 +0100 Subject: [PATCH 17/19] refactoring: added comments in test --- test/gaussscheSummenformel/test_gaussscheSummenformel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/gaussscheSummenformel/test_gaussscheSummenformel.c b/test/gaussscheSummenformel/test_gaussscheSummenformel.c index 99a9219..96a9e2b 100644 --- a/test/gaussscheSummenformel/test_gaussscheSummenformel.c +++ b/test/gaussscheSummenformel/test_gaussscheSummenformel.c @@ -6,9 +6,9 @@ void tearDown(){} void test_gaussscheSummenformel() { - TEST_ASSERT_EQUAL_INT(1, gaussscheSummenformel(1)); - TEST_ASSERT_EQUAL_INT(15, gaussscheSummenformel(5)); - TEST_ASSERT_EQUAL_INT(55, gaussscheSummenformel(10)); - TEST_ASSERT_EQUAL_INT(5050, gaussscheSummenformel(100)); + TEST_ASSERT_EQUAL_INT(1, gaussscheSummenformel(1)); // sum of the first 1 numbers + TEST_ASSERT_EQUAL_INT(15, gaussscheSummenformel(5)); // sum of the first 5 numbers + TEST_ASSERT_EQUAL_INT(55, gaussscheSummenformel(10)); // sum of the first 10 numbers + TEST_ASSERT_EQUAL_INT(5050, gaussscheSummenformel(100));// sum of the first 100 numbers } \ No newline at end of file From c4b75b1b9d6d9a0667a9edadc0f226a88b37d981 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 21:35:26 +0100 Subject: [PATCH 18/19] refactoring: function got smaller --- src/gaussscheSummenformel/gaussscheSummenformel.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index 986ae81..d4b9912 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -2,9 +2,5 @@ int gaussscheSummenformel(int n) { - int result = n * (n + 1); - - result = result / 2; - - return result; + return (n * (n + 1)) / 2; } \ No newline at end of file From d5e2f90fe28305ca442539af6ab0c8caf1d5d2c2 Mon Sep 17 00:00:00 2001 From: Hendrik Sitzmann Date: Thu, 8 Feb 2024 21:38:07 +0100 Subject: [PATCH 19/19] refactoring: added comment in function --- src/gaussscheSummenformel/gaussscheSummenformel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gaussscheSummenformel/gaussscheSummenformel.c b/src/gaussscheSummenformel/gaussscheSummenformel.c index d4b9912..906d7c8 100644 --- a/src/gaussscheSummenformel/gaussscheSummenformel.c +++ b/src/gaussscheSummenformel/gaussscheSummenformel.c @@ -1,6 +1,7 @@ #include int gaussscheSummenformel(int n) { - + + //ergibt die Summe der ersten n natürlichen Zahlen return (n * (n + 1)) / 2; } \ No newline at end of file