SPEED problem

I am not getting the solution of this problem SPEED (ie ans= (a-b)/gcd(a,b))
.Can anyone explain it! Thanks in advance!