Last active
August 26, 2021 10:47
-
-
Save avii-7/26e2308845cf3f559df31000d5b4e4e1 to your computer and use it in GitHub Desktop.
Write a function to compute the greatest common divisor given by Euclid’s algorithm, exemplified for j = 1980, K = 1617 as follows:- 33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void gcd(int, int); | |
int main() | |
{ | |
int num1, num2; | |
printf("Enter two numbers: "); | |
scanf("%d %d", &num1, &num2); | |
gcd((num1 >= num2) ? num1, num2 : num2, num1); | |
return 0; | |
} | |
void gcd(int big, int small) | |
{ | |
(small != 0) ? gcd(small, big % small) : printf("GCD is: %d.", big); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment