From ff9378fa7274562ac860c672a3da04d97ba736c2 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 13:35:16 +0100 Subject: [PATCH 01/21] ProduktSumme file erstellt --- src/ProduktSumme.c | 5 +++++ src/ProduktSumme.h | 8 ++++++++ test/test_ProduktSumme.c | 15 +++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/ProduktSumme.c create mode 100644 src/ProduktSumme.h create mode 100644 test/test_ProduktSumme.c diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c new file mode 100644 index 0000000..f5bcf41 --- /dev/null +++ b/src/ProduktSumme.c @@ -0,0 +1,5 @@ +// +// Created by Justin Trausch on 06.02.2024. +// + +#include "ProduktSumme.h" diff --git a/src/ProduktSumme.h b/src/ProduktSumme.h new file mode 100644 index 0000000..aa9d551 --- /dev/null +++ b/src/ProduktSumme.h @@ -0,0 +1,8 @@ +// +// Created by Justin Trausch on 06.02.2024. +// + +#ifndef LINKES_TWIX_PRODUKTSUMME_H +#define LINKES_TWIX_PRODUKTSUMME_H + +#endif //LINKES_TWIX_PRODUKTSUMME_H diff --git a/test/test_ProduktSumme.c b/test/test_ProduktSumme.c new file mode 100644 index 0000000..c3fe8e6 --- /dev/null +++ b/test/test_ProduktSumme.c @@ -0,0 +1,15 @@ +#ifdef TEST + +#include "unity.h" + +#include "ProduktSumme.h" + + +void setUp(void) +{ +} + +void tearDown(void) +{ +} +#endif //TEST From bf3426a6c092122b28cd0f540707b66582570b59 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 13:43:02 +0100 Subject: [PATCH 02/21] Produkt Basisfall: Produkt bis 1 --- src/ProduktSumme.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index f5bcf41..0cc016c 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -1,5 +1,8 @@ // // Created by Justin Trausch on 06.02.2024. -// +#include -#include "ProduktSumme.h" +// Funktion zur Berechnung des Produktsymbols +int berechneProdukt(int start, int ende) { + return 1; +} \ No newline at end of file From 4f96ac6a9b36f8235dbf6f0527c340b52c25bdb9 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 13:56:14 +0100 Subject: [PATCH 03/21] =?UTF-8?q?Produkt=20Basisfall=20f=C3=BCr=20Start=3D?= =?UTF-8?q?1=20und=20Ende=3D1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.h | 1 + test/test_ProduktSumme.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ProduktSumme.h b/src/ProduktSumme.h index aa9d551..93f60e5 100644 --- a/src/ProduktSumme.h +++ b/src/ProduktSumme.h @@ -4,5 +4,6 @@ #ifndef LINKES_TWIX_PRODUKTSUMME_H #define LINKES_TWIX_PRODUKTSUMME_H +int berechneProdukt(int, int); #endif //LINKES_TWIX_PRODUKTSUMME_H diff --git a/test/test_ProduktSumme.c b/test/test_ProduktSumme.c index c3fe8e6..a7dcbd1 100644 --- a/test/test_ProduktSumme.c +++ b/test/test_ProduktSumme.c @@ -12,4 +12,15 @@ void setUp(void) void tearDown(void) { } + +void test_produkt_1(void) +{ + int result, expected = 1; + + result = berechneProdukt(1,1); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + + #endif //TEST From 0d6153e84f5bfc77d1140109ba751a0e7207a483 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:52:05 +0100 Subject: [PATCH 04/21] Initialisierung der Variable "produkt" --- src/ProduktSumme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 0cc016c..37022ef 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -4,5 +4,6 @@ // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { + int produkt = 1; return 1; } \ No newline at end of file From 0eabb131176320d176ee9ecf48bffced5808a76e Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:53:56 +0100 Subject: [PATCH 05/21] =?UTF-8?q?For-Schleife=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 37022ef..d2f3a0b 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -5,5 +5,8 @@ // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { int produkt = 1; + for (int i = start; i <= ende; i++) { + + } return 1; } \ No newline at end of file From 92836654bca6ac4d9c4727451f485318af665c75 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:56:54 +0100 Subject: [PATCH 06/21] =?UTF-8?q?For-Schleife=20Kalkulation=20eingef=C3=BC?= =?UTF-8?q?gt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index d2f3a0b..c6fcb53 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -6,7 +6,7 @@ int berechneProdukt(int start, int ende) { int produkt = 1; for (int i = start; i <= ende; i++) { - + produkt = produkt * i; } return 1; } \ No newline at end of file From 94a2d06345f2e2025720492d11b6903a0744d8c9 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:58:36 +0100 Subject: [PATCH 07/21] refactoring: Brechnung vereinfacht --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index c6fcb53..4230d5e 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -6,7 +6,7 @@ int berechneProdukt(int start, int ende) { int produkt = 1; for (int i = start; i <= ende; i++) { - produkt = produkt * i; + produkt *= i; } return 1; } \ No newline at end of file From ad3784984b9b605641eef1708158f728ff8706d4 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:59:42 +0100 Subject: [PATCH 08/21] refactoring: return statement vereinfacht --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 4230d5e..21a1ca8 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -8,5 +8,5 @@ int berechneProdukt(int start, int ende) { for (int i = start; i <= ende; i++) { produkt *= i; } - return 1; + return produkt; } \ No newline at end of file From be2504b7d08b2822ce662d69952b98e12694b081 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:20:51 +0100 Subject: [PATCH 09/21] =?UTF-8?q?Basiertes=20Verbindlichkeit=20(weiter=20F?= =?UTF-8?q?or=20schleife=20hinzugef=C3=BCgt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 21a1ca8..0d3db9e 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -8,5 +8,12 @@ int berechneProdukt(int start, int ende) { for (int i = start; i <= ende; i++) { produkt *= i; } + for (int j = start; j <= ende; j++) { + for (int k = start; k <= ende; k++) { + for (int g = k; g <= ende; g++){ + produkt *= j + k -g; + } + } + } return produkt; } \ No newline at end of file From 67c0b2999fe0195dd27d0ec89051e6115ccb2179 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:29:07 +0100 Subject: [PATCH 10/21] Planung Kommentare Ideen Produkt --- src/ProduktSumme.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 0d3db9e..0899097 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -2,6 +2,20 @@ // Created by Justin Trausch on 06.02.2024. #include +// Int produkt +// double Produkt +// Bitshift bei Multiplikation mit 2er Potenzen +// +//6713 * 2^1 +// +// +//6713 << 1 +//6713 * 16 = 2^4 +//6713 << 4 +//2^n +//x << n + + // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { int produkt = 1; From 9abca4b85c0b84fdd88876b65185101f6c5e8e5a Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 13:56:14 +0100 Subject: [PATCH 11/21] =?UTF-8?q?test=5Fprodukt=5F1=20f=C3=BCr=20Start=3D1?= =?UTF-8?q?=20und=20Ende=3D1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.h | 1 + test/test_ProduktSumme.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ProduktSumme.h b/src/ProduktSumme.h index aa9d551..93f60e5 100644 --- a/src/ProduktSumme.h +++ b/src/ProduktSumme.h @@ -4,5 +4,6 @@ #ifndef LINKES_TWIX_PRODUKTSUMME_H #define LINKES_TWIX_PRODUKTSUMME_H +int berechneProdukt(int, int); #endif //LINKES_TWIX_PRODUKTSUMME_H diff --git a/test/test_ProduktSumme.c b/test/test_ProduktSumme.c index c3fe8e6..a7dcbd1 100644 --- a/test/test_ProduktSumme.c +++ b/test/test_ProduktSumme.c @@ -12,4 +12,15 @@ void setUp(void) void tearDown(void) { } + +void test_produkt_1(void) +{ + int result, expected = 1; + + result = berechneProdukt(1,1); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + + #endif //TEST From 943c24232bc13ed2bf9746481b6890e96fbbbaa3 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:52:05 +0100 Subject: [PATCH 12/21] Initialisierung der Variable "produkt" --- src/ProduktSumme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 0cc016c..37022ef 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -4,5 +4,6 @@ // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { + int produkt = 1; return 1; } \ No newline at end of file From 33650e91c0d73577e7804d5b192cf8e03f658299 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:53:56 +0100 Subject: [PATCH 13/21] =?UTF-8?q?For-Schleife=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 37022ef..d2f3a0b 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -5,5 +5,8 @@ // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { int produkt = 1; + for (int i = start; i <= ende; i++) { + + } return 1; } \ No newline at end of file From 9aee9686c0e5cd25a446c58240e9304de226aa39 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:56:54 +0100 Subject: [PATCH 14/21] =?UTF-8?q?For-Schleife=20Kalkulation=20eingef=C3=BC?= =?UTF-8?q?gt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index d2f3a0b..c6fcb53 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -6,7 +6,7 @@ int berechneProdukt(int start, int ende) { int produkt = 1; for (int i = start; i <= ende; i++) { - + produkt = produkt * i; } return 1; } \ No newline at end of file From 75ff27515e452ddb8ab3e5d1311b552a62a11ebb Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:58:36 +0100 Subject: [PATCH 15/21] refactoring: Brechnung vereinfacht --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index c6fcb53..4230d5e 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -6,7 +6,7 @@ int berechneProdukt(int start, int ende) { int produkt = 1; for (int i = start; i <= ende; i++) { - produkt = produkt * i; + produkt *= i; } return 1; } \ No newline at end of file From 3b4ac06707a06cd4ae197187d4ef84d05994a0ef Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:59:42 +0100 Subject: [PATCH 16/21] refactoring: return statement vereinfacht --- src/ProduktSumme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 4230d5e..21a1ca8 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -8,5 +8,5 @@ int berechneProdukt(int start, int ende) { for (int i = start; i <= ende; i++) { produkt *= i; } - return 1; + return produkt; } \ No newline at end of file From 8039d9b249b39ec1993cd576caa42a2ec7bf0e04 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:20:51 +0100 Subject: [PATCH 17/21] =?UTF-8?q?Basiertes=20Verbindlichkeit=20(weiter=20F?= =?UTF-8?q?or=20schleife=20hinzugef=C3=BCgt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 21a1ca8..0d3db9e 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -8,5 +8,12 @@ int berechneProdukt(int start, int ende) { for (int i = start; i <= ende; i++) { produkt *= i; } + for (int j = start; j <= ende; j++) { + for (int k = start; k <= ende; k++) { + for (int g = k; g <= ende; g++){ + produkt *= j + k -g; + } + } + } return produkt; } \ No newline at end of file From 5b89eaf77c798c74868633f5cb87fbd38b338a21 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 17:29:07 +0100 Subject: [PATCH 18/21] Planung Kommentare Ideen Produkt --- src/ProduktSumme.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ProduktSumme.c b/src/ProduktSumme.c index 0d3db9e..0899097 100644 --- a/src/ProduktSumme.c +++ b/src/ProduktSumme.c @@ -2,6 +2,20 @@ // Created by Justin Trausch on 06.02.2024. #include +// Int produkt +// double Produkt +// Bitshift bei Multiplikation mit 2er Potenzen +// +//6713 * 2^1 +// +// +//6713 << 1 +//6713 * 16 = 2^4 +//6713 << 4 +//2^n +//x << n + + // Funktion zur Berechnung des Produktsymbols int berechneProdukt(int start, int ende) { int produkt = 1; From 7ab18bca66b3a907e6d34c944117262563528d58 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 20:57:16 +0100 Subject: [PATCH 19/21] =?UTF-8?q?refactoring:=20int=20start,=20ende=20erg?= =?UTF-8?q?=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProduktSumme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProduktSumme.h b/src/ProduktSumme.h index 93f60e5..80ff3ff 100644 --- a/src/ProduktSumme.h +++ b/src/ProduktSumme.h @@ -4,6 +4,6 @@ #ifndef LINKES_TWIX_PRODUKTSUMME_H #define LINKES_TWIX_PRODUKTSUMME_H -int berechneProdukt(int, int); +int berechneProdukt(int start, int ende); #endif //LINKES_TWIX_PRODUKTSUMME_H From b201c968d27ac2230d7b4d245a9f3608c162e285 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:43:18 +0100 Subject: [PATCH 20/21] 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 From e2b3066922c2a3cce244428c1c4bf517977b001e Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Wed, 7 Feb 2024 21:47:03 +0100 Subject: [PATCH 21/21] test_Summe_1 Start = 1 und Ende = 10 --- test/test_ProduktSumme.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_ProduktSumme.c b/test/test_ProduktSumme.c index a7dcbd1..5a27f35 100644 --- a/test/test_ProduktSumme.c +++ b/test/test_ProduktSumme.c @@ -22,5 +22,15 @@ void test_produkt_1(void) TEST_ASSERT_EQUAL_INT(expected, result); } +void test_Summe_1(void) +{ + int result, expected = 55; + + result = berechneSumme(1,10); + + TEST_ASSERT_EQUAL_INT(expected, result); +} + + #endif //TEST