From 4f96ac6a9b36f8235dbf6f0527c340b52c25bdb9 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 13:56:14 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Produkt=20Basisfall=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 0d6153e84f5bfc77d1140109ba751a0e7207a483 Mon Sep 17 00:00:00 2001 From: Justin Trausch Date: Tue, 6 Feb 2024 14:52:05 +0100 Subject: [PATCH 2/8] 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 3/8] =?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 4/8] =?UTF-8?q?For-Schleife=20Kalkulation=20eingef=C3=BCgt?= 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 5/8] 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 6/8] 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 7/8] =?UTF-8?q?Basiertes=20Verbindlichkeit=20(weiter=20For?= =?UTF-8?q?=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 8/8] 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;