Skip to content

Commit 25b2867

Browse files
authored
Update day13.py
1 parent e1d03a1 commit 25b2867

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

day13.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
def modular_multiplicative_inverse(a: int, m: int) -> int:
2-
# ref: https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
3-
if m == 1:
4-
return 0
5-
6-
m0, y, x = m, 0, 1
7-
while a > 1:
8-
q = a // m
9-
a, m = m, a % m
10-
x, y = y, x - q * y
11-
12-
return x + m0 if x < 0 else x
2+
# ref: https://docs.python.org/3/whatsnew/3.8.html
3+
return pow(a, -1, m)
134

145

156
def chinese_remainder_theorem_solver(divisors_and_remainders: list) -> int:

0 commit comments

Comments
 (0)