I was thinking about an algorithm to solve the congruence ax = 1 mod p with p prime.
I was thinking about using Fermat theorem. Since I know that
There is no reason this isn't a good algorithm for computers, you just need to be careful about the implementation, which isn't exactly trivial I guess, but it's not difficult either.
Just use exponentiation by squaring, then it most likely won't matter how big p is.
a^n = a^(n / 2) * a^(n / 2) for n even
= a*a^(n - 1) for n odd