# What is the Voronoi's formula to calculate the inverse modulo m $ax \equiv 1 \pmod{m}$

I searched a bit using google but I found nothing :( ! Any information would be greatly appreciated.

Thank you,

-
Is it possible you've mixed it up with something else? Where did you hear about this formula? –  Zev Chonoles Apr 25 '11 at 5:20
@Zev Chonoles: It was from my lecture notes. My teacher said there were 3 methods to calculate the inverse, first one is extended Euclidean, second one is $a^{\phi(m) - 1 } \pmod{m}$, and third one is Voronoi. –  Chan Apr 25 '11 at 5:22

If we have $ax \equiv 1 \pmod m$ and we have that $\gcd(a,m) = 1$ (as otherwise we know that there is no solution), then the solution is given by $$x \equiv \left(3 - 2a + 6 \sum\limits_{k=1}^{a-1} \left\lfloor \frac{mk}{a} \right\rfloor^2 \right) \pmod m$$