I have tried to follow the previous posts and I'm still confused.

I can follow the Euclidean algorithm to find gcd and I know that gcd has to equal 1 for there to be an inverse, in other words a and m have to be relatively prime, but could someone lay out the steps? Let a=4 and m=9.

Then 9 = 2(4) + 1

and 4 = 4(1) + 0

so 1 = 9 - 2(4)

Then do you set 4p = 1 (mod 9) ?

I really don't understand how the process (algorithm) continues.