# Revision history [back]

### Inverse of a number module 2**255 -19

I don't understand this code to solve the inverse of a number:

b = 256;
q = 2**255 - 19

def expmod(b,e,m):
if e == 0: return 1
t = expmod(b,e/2,m)**2 % m
if e & 1: t = (t*b) % m
return t

def inv(x):
return expmod(x,q-2,q)


Finally, If I want to put: $\frac{2}{3}$ I can to do this: aux=2*inv(3)

What does the variable e mean?

Could you explain me this code, please?

Thank you so much.

 2 None slelievre 14394 ●16 ●135 ●284 http://carva.org/samue...

### Inverse of a number module 2**255 -19

I don't understand this code to solve the inverse of a number:

b = 256;
q = 2**255 - 19

def expmod(b,e,m):
if e == 0: return 1
t = expmod(b,e/2,m)**2 % m
if e & 1: t = (t*b) % m
return t

def inv(x):
return expmod(x,q-2,q)


Finally, If I want to put: $\frac{2}{3}$ I can to do this: aux=2*inv(3)

What does the variable e mean?

Could you explain me this code, please?

Thank you so much.