Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Modular-inverse/ASIC/modular-inverse.asic
Normal file
29
Task/Modular-inverse/ASIC/modular-inverse.asic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
REM Modular inverse
|
||||
E = 42
|
||||
T = 2017
|
||||
GOSUB CalcModInv:
|
||||
PRINT ModInv
|
||||
END
|
||||
|
||||
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
|
||||
IF E < T THEN
|
||||
Bal = E
|
||||
Count = 1
|
||||
Loop:
|
||||
Step = T - Bal
|
||||
Step = Step / E
|
||||
Step = Step + 1
|
||||
REM So ... Step = (T - Bal) / E + 1
|
||||
StepTimesE = Step * E
|
||||
Bal = Bal + StepTimesE
|
||||
Count = Count + Step
|
||||
Bal = Bal - T
|
||||
IF Bal <> 1 THEN Loop:
|
||||
D = Count
|
||||
ENDIF
|
||||
ModInv = D
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue