This is from an earlier hw assignment I got wrong

prove that for all positive integers a and b, a|b if and only if , gcd(a, b) = a

first I thought since gcd(a, b) = a. Then a divided into itself and b.

a|b --> b = ac for some int c

let f - gcd(a, b) = gcd(a, ac)

Im not sure I have it right to this point or what to do next>?(Doh)

Thank you