Extended gcd-067
Extended gcd-067
Aim:
To write a c code for execute GCD and Multiplicative inverse using Extended Euclidean algorithm.
Algorithm:
Step 1: Define a function to compute the GCD using the Extended Euclidean algorithm.
Step 4: Compute the GCD of the integers and print the result.
Program:
#include <stdio.h>
if (b == 0) {
*x = 1;
*y = 0;
return a;
*x = y1;
*y = x1 - (a / b) * y1;
return gcd;
if (gcd != 1) {
return -1;
int inverse = (x % m + m) % m;
return inverse;
int main() {
int a, b;
int x, y;
if (inverse != -1) {
} else {
printf("RRN:220171601067\n");
return 0; }
Output:
Review Questions:
Result:
Thus, the program to execute GCD and Multiplicative inverse using Extended Euclidean algorithm
has been successfully verified and executed.