11th Jan 2024, 4:13 PM
Pravin
Pravin - avatar
5 odpowiedzi
+ 5
From what I see, the "go" object is trying to find n such that the modular multiplicative inverse of 1 (mod 223) is congruent to mod 223 of n*(x2-x1) - and the pow() function does it well. To find the modular multiplicative inverse without using the pow function, you can use the Extended Euclidean Algorithm: def extended_gcd(a, b): if b == 0: return a, 1, 0 else: d, x, y = extended_gcd(b, a % b) return d, y, x - (a // b) * y def modular_inverse(a, m): d, x, y = extended_gcd(a, m) if d != 1: raise ValueError(f"The modular inverse does not exist for {a} (mod {m}).") return x % m x1 = 192 y1 = 105 x2 = 17 y2 = 56 mod_inv = modular_inverse(x2 - x1, 223) print(mod_inv)
11th Jan 2024, 6:34 PM
Jacob Morgunov
Jacob Morgunov - avatar
+ 5
Jacob Morgunov How difficult it is...🤔 And this is a child's task...😎 i=2 while(i*(x2-x1)%223!=1): i+=1 print(i) #=79
12th Jan 2024, 10:38 AM
Solo
Solo - avatar
+ 4
I'm pretty sure the easiest way is to think about what does "pow" do? How does it do it? Once you answer those 2 questions, you should be able to write the code without it.
11th Jan 2024, 4:38 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Pravin , Do you know this operator? ** See the table. https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
12th Jan 2024, 7:52 AM
Rain
Rain - avatar
0
Hey
12th Jan 2024, 12:42 PM
KinQkc
KinQkc - avatar