-4
(x/y) mod n = ((x mod n) * (y mod n)^-1) mod n

I would like to know how to convert the above statement into python.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • 1
    What specific part of that do you already know how to do? What part _don't_ you know how to do? Do you know how to do a modulo at all, in general? What research have you done? How close have you gotten to a correct solution? – Charles Duffy Feb 05 '21 at 18:30
  • Also, build a title to be talking about _the problem_, not about _you_. The goal is that the question and its answers should be helpful to everyone with the same issue, so other people trying to figure out how to do the same specific thing should be able to find it and learn from its answers. – Charles Duffy Feb 05 '21 at 18:30
  • ...as an example of a preexisting question that covers a lot of the same space, see [How to calculate a mod b in python?](https://stackoverflow.com/questions/991027/how-to-calculate-a-mod-b-in-python) -- to prevent this question from being duplicate, it would help to show where you get stuck when trying to apply that preexisting question's answers. – Charles Duffy Feb 05 '21 at 18:32

1 Answers1

0

You can do something like this,

consider,

x=10
y=5
n=2
# You can use if condition to evaluate the expression
if (x/y)%n==((x%n)*(y%n)**(-1)):
    print('Condition satisfied')
else:
    print('Condition not satisfied')
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
shajahan
  • 102
  • 3