program main implicit none integer*8::a,b,c,ab,abc,aa,bb,cc,div integer*8::i read *,a,b,c ab = lcm(a,b) abc = lcm(ab,c) aa = abc/a bb = abc/b cc = abc/c do i=MIN(MIN(aa,bb),cc),1,-1 if(MOD(aa,i).eq.MOD(bb,i) .and.& MOD(aa,i).eq.MOD(cc,i)) then exit end if end do div = gcd(abc,i) print '(i0,"/",i0)',abc/div,i/div 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 function lcm(a,b) result(c) integer*8,intent(in)::a,b integer*8::c c = (a*b)/gcd(a,b) end function lcm end program main