This version is for RSA public-key encryption method.
e*d mod z =1
it takes the value of e or d and returns the value of d or e respectively.
#include <stdio.h>
#include <string.h>
int z,ed;
int ee_algo(int x1,int x2,int x3,int y1,int y2,int y3)
{ int q=x3/y3;
int tx1=y1;
int tx2=y2;
int tx3=y3;
y1=x1-q*y1;
y2=x2-q*y2;
y3=x3-q*y3;
if(y3==1)
{ if(y2>0)
return y2;
else return y2+z;
}
else
{ x1=tx1;
x2=tx2;
x3=tx3;
return ee_algo(x1,x2,x3,y1,y2,y3);
}
}
main()
{
z=2400;
ed=29;
printf("%d",ee_algo(1,0,z,0,1,ed));
}
e*d mod z =1
it takes the value of e or d and returns the value of d or e respectively.
#include <stdio.h>
#include <string.h>
int z,ed;
int ee_algo(int x1,int x2,int x3,int y1,int y2,int y3)
{ int q=x3/y3;
int tx1=y1;
int tx2=y2;
int tx3=y3;
y1=x1-q*y1;
y2=x2-q*y2;
y3=x3-q*y3;
if(y3==1)
{ if(y2>0)
return y2;
else return y2+z;
}
else
{ x1=tx1;
x2=tx2;
x3=tx3;
return ee_algo(x1,x2,x3,y1,y2,y3);
}
}
main()
{
z=2400;
ed=29;
printf("%d",ee_algo(1,0,z,0,1,ed));
}