Extended Euclids Algorithm
Extended Euclids Algorithm
AIM:
To write a C++ program to find the greatest common divisor using euclid’s
theorem.
ALGORITHM:
Step 1: Start
Step 4: According to the input given, the gcd of the two numbers is
calculated using the euclid’s theorem.
Step 6: Stop
SOURCE CODE:
#include <bits/stdc++.h>
// Base Case
if (a == 0)
*x = 0;
*y = 1;
return b;
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
int main()
int x, y, a, b;
return 0;
OUTPUT:
RESULT:
The gcd was found and the output was successfully displayed on the screen.