Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Modular-inverse/PL-I/modular-inverse.pli
Normal file
33
Task/Modular-inverse/PL-I/modular-inverse.pli
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
*process source attributes xref or(!);
|
||||
/*--------------------------------------------------------------------
|
||||
* 13.07.2015 Walter Pachl
|
||||
*-------------------------------------------------------------------*/
|
||||
minv: Proc Options(main);
|
||||
Dcl (x,y) Bin Fixed(31);
|
||||
x=42;
|
||||
y=2017;
|
||||
Put Edit('modular inverse of',x,' by ',y,' ---> ',modinv(x,y))
|
||||
(Skip,3(a,f(4)));
|
||||
modinv: Proc(a,b) Returns(Bin Fixed(31));
|
||||
Dcl (a,b,ob,ox,d,t) Bin Fixed(31);
|
||||
ob=b;
|
||||
ox=0;
|
||||
d=1;
|
||||
|
||||
If b=1 Then;
|
||||
Else Do;
|
||||
Do While(a>1);
|
||||
q=a/b;
|
||||
r=mod(a,b);
|
||||
a=b;
|
||||
b=r;
|
||||
t=ox;
|
||||
ox=d-q*ox;
|
||||
d=t;
|
||||
End;
|
||||
End;
|
||||
If d<0 Then
|
||||
d=d+ob;
|
||||
Return(d);
|
||||
End;
|
||||
End;
|
||||
Loading…
Add table
Add a link
Reference in a new issue