program main implicit none integer*8::N,org,upper,i,j integer*8,allocatable::furui(:) read *,N do if(MOD(N,2).eq.1) exit N = N/2 end do org = N upper = INT(SQRT(DBLE(N)+1)) allocate(furui(3:upper)) furui = 0 do i=3,upper,2 if(furui(i).ne.0) cycle if(MOD(N,i).eq.0) then print '(i0)',i return end if do j=i+i,upper,i furui(j) = 1 end do end do print '(i0)',org end program main