From cc5080504ad9a9d5726be8e74d09fb54171e2973 Mon Sep 17 00:00:00 2001 From: Hyder Date: Tue, 22 Jul 2025 13:17:24 +0300 Subject: This is a Greatest Common Divisor in C language --- GCD.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 GCD.c diff --git a/GCD.c b/GCD.c new file mode 100644 index 0000000..2f857f8 --- /dev/null +++ b/GCD.c @@ -0,0 +1,23 @@ +# include + +int GreatestCommonDivisor(int INPUT_ONE, int INPUT_TWO) { + int DIVISOR; + for (int i = 1; i < INPUT_ONE || i < INPUT_TWO;++i) { + if (INPUT_ONE % i == 0 && INPUT_TWO % i == 0) { + DIVISOR = i; + } + } + return DIVISOR; +} + + +int main() { + int INPUT_ONE; + int INPUT_TWO; + printf("Give me a TWO numbers to find GCD\n"); + while (scanf("%d %d", &INPUT_ONE, &INPUT_TWO) != EOF) { + int RESULT = GreatestCommonDivisor(INPUT_ONE, INPUT_TWO); + printf("%d\n\n", RESULT); + } + return 0; +} \ No newline at end of file -- cgit v1.2.3