Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,18 @@
10 LET E = 42
20 LET T = 2017
30 GOSUB 500" MODULAR INVERSE
40 PRINT M;
50 END
REM MODULAR INVERSE
500 LET M = 0
510 IF E > = T THEN RETURN
520 LET C = 1
530 FOR B = E TO 1 STEP 0
540 LET S = INT ((T - B) / E) + 1
550 LET B = B + S * E
560 LET C = C + S
570 LET B = B - T
580 NEXT B
590 LET M = C
610 RETURN

View file

@ -9,3 +9,7 @@ sub inverse($n, :$modulo) {
}
say inverse 42, :modulo(2017)
# or use a built-in routine - https://docs.raku.org/routine/expmod , kudos to trizen++
say expmod(42, -1, 2017);

View file

@ -0,0 +1,19 @@
print multInv(42, 2017)
end
sub multInv(a,b)
x0 = 0
b0 = b
multInv = 1
if b = 1 return
while a > 1
q = a / b
t = b
b = mod (a, b)
a = t
t = x0
x0 = multInv - q * x0
multInv = int(t)
wend
if multInv < 0 return multInv + b0
end sub