program main implicit none integer*8::A,B,AA,BB,CC,AB read *,A,B AB = gcd(A,B) A = A/AB B = B/AB print '(i0)',gcd(A+B,A*B*AB)*AB contains recursive function gcd(a,b) result(c) integer*8::a,b,c if(b.eq.0) then c = a else c = gcd(b,MOD(a,b)) end if end function gcd end program main