Browse Source

Merge branch 'kgV' into 'master'

better var naming

See merge request fdai8031/cstools101!7
remotes/origin/userinput
fdai7777 11 months ago
parent
commit
1044f37dc7
  1. 8
      src/kgV/kgV.c
  2. 2
      src/kgV/kgV.h
  3. 2
      test/kgV/test_kgV.c

8
src/kgV/kgV.c

@ -2,16 +2,16 @@
#include <stdlib.h> #include <stdlib.h>
#include "ggT.h" #include "ggT.h"
int kgV(int a, int b){
int kgV(int fistNumber, int secondNumber){
// Case for at least one number is Zero // Case for at least one number is Zero
if(a == 0 || b == 0) return 0;
if(fistNumber == 0 || secondNumber == 0) return 0;
// Regular case of calculating the kgV // Regular case of calculating the kgV
int kgV = a*b/ ggT(a, b);
int kgVResult = fistNumber*secondNumber/ ggT(fistNumber, secondNumber);
// Getting the absolute value of the kgV // Getting the absolute value of the kgV
int absoluteKgV = abs(kgV);
int absoluteKgV = abs(kgVResult);
return absoluteKgV; return absoluteKgV;
} }

2
src/kgV/kgV.h

@ -1,6 +1,6 @@
#ifndef KGV_H #ifndef KGV_H
#define KGV_H #define KGV_H
int kgV(int a, int b);
int kgV(int firstNumber, int secondNumber);
#endif #endif

2
test/kgV/test_kgV.c

@ -6,7 +6,7 @@ void setUp(void){}
void tearDown(void){} void tearDown(void){}
// Tests for common Cases: // Tests for common Cases:
void test_kgV8And6(void) {
void test_kgVOf8And6(void) {
TEST_ASSERT_EQUAL_INT(24, kgV(8, 6)); TEST_ASSERT_EQUAL_INT(24, kgV(8, 6));
} }

Loading…
Cancel
Save