Skip to content

Instantly share code, notes, and snippets.

@avii-7
Last active August 26, 2021 10:47
Show Gist options
  • Save avii-7/26e2308845cf3f559df31000d5b4e4e1 to your computer and use it in GitHub Desktop.
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
#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