This function used the above inversion of a to find x = (b*a^(-1))mod n >>> modular_division2(4,8,5) 2 >>> modular_division2(3,8,5) 1 >>> modular_division2(4, 11, 5) 4
(a: int, b: int, n: int)
| 61 | |
| 62 | |
| 63 | def modular_division2(a: int, b: int, n: int) -> int: |
| 64 | """ |
| 65 | This function used the above inversion of a to find x = (b*a^(-1))mod n |
| 66 | |
| 67 | >>> modular_division2(4,8,5) |
| 68 | 2 |
| 69 | |
| 70 | >>> modular_division2(3,8,5) |
| 71 | 1 |
| 72 | |
| 73 | >>> modular_division2(4, 11, 5) |
| 74 | 4 |
| 75 | |
| 76 | """ |
| 77 | s = invert_modulo(a, n) |
| 78 | x = (b * s) % n |
| 79 | return x |
| 80 | |
| 81 | |
| 82 | def extended_gcd(a: int, b: int) -> tuple[int, int, int]: |
nothing calls this directly
no test coverage detected