Jump to content

Modular inverse: Difference between revisions

(Add Cowgol)
Line 289:
CalcModInv:
REM Increments E Step times until Bal is greater than T
REM Repeats until Bal = 1 (MOD = 1) and returns Count
REM Bal will not be greater than T + E
D = 0
Line 314:
1969
</pre>
 
==={{header|Minimal BASIC}}===
{{trans|Pascal}}
{{works with|Commodore BASIC|3.5}}
{{works with|Nascom ROM BASIC|4.7}}
<lang gwbasic>
10 REM Modular inverse
20 LET E = 42
30 LET T = 2017
40 GOSUB 500
50 PRINT M
60 END
490 REM Calculate modular inverse
500 LET D = 0
510 IF E >= T THEN 600
520 LET B = E
530 LET C = 1
540 LET S1 = INT((T-B)/E)+1
550 LET B = B+S1*E
560 LET C = C+S1
570 LET B = B-T
580 IF B <> 1 THEN 540
590 LET D = C
600 LET M = D
610 RETURN
</lang>
 
=={{header|Batch File}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.