相关代码 |
|
import java.io.*; public class function { public int function (int d,int f ){ int x1=1,x2=0,y1=0,y2=1,x3=f,y3=d,q=0; int t1,t2,t3,temp; for(; ;){ temp=x3; if (y3==0) {y2=NULL;System.out.println("无逆元");break;} if (y3==1) break; while(x3>=y3){ q++; x3=x3-y3; } x3=temp; t1=x1-q*y1;t2=x2-q*y2;t3=x3-q*y3; x1=y1;x2=y2;x3=y3; y1=t1;y2=t2;y3=t3; q=0; } if (y2>0) {y2=y2%f;} if (y2 return y2; } }