program main implicit none integer*8::A,B,AA,BB,AB,ABA,ABB read *,A,B AB = gcd(A,B) A = A/AB B = B/AB ABA= gcd(A+B,A) ABB= gcd(A+B,B) print '(i0)',ABA*ABB*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