program main implicit none integer*8::N,upper,i,j integer*8,allocatable::furui(:) read *,N upper = INT(SQRT(DBLE(N)+1)) allocate(furui(2:upper)) if(MOD(N,3).eq.0) then print '(a)',"3" return else if(MOD(N,4).eq.0) then print '(a)',"4" return end if if(MOD(N,2).eq.0) N = N/2 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)',N end program main