You are on page 1of 1

#include <stdio.

h>
#include <stdlib.h>
int extended_euclid(int a,int b)
{
int r1,r2,s1,s2,t1,t2,r,s,t,q,res;
r1=a;r2=b;
s1=1;s2=0;
t1=0;t2=1;
while(r2>0)
{
q=r1/r2;
r=r1-q*r2;
r1=r2;
r2=r;
s=s1-q*s2;
s1=s2;
s2=s;
t=t1-q*t2;
t1=t2;
t2=t;
}
res=r1;
s=s1;t=t1;
printf("Gcd of two numbers is %d",res);
printf("printing s:%d and t:%d",s,t);

}
int main()
{
int a,b,res;
printf("Enter the Value of a:");
scanf("%d",&a);
printf("Enter the Value of b:");
scanf("%d",&b);
extended_euclid(a,b);
}

You might also like