Suppose 0< a< p. a is 'invertible' if there exist b, 0< b< p, such that ab= 1 (mod p). And that is true if and only if there exist an integer n such that ab= np+ 1. That is the same as ab- np= 1 where a, b, n, and p are integers. That is where you can use the "Euclidean Algorithm".