Easy solution using stl


#1

int ans=__gcd(A,B);
return ans;