program main implicit none integer*8::N,M,i,digit integer,allocatable::L(:) read *,N M=7 do i=1,20 if(M.gt.N) exit M=M*7 end do digit=i allocate(L(digit)) do i=digit, 1, -1 L(i) = MOD(N,7) N=N/7 end do do i=1,digit write (*,'(i0)',advance='no'),L(i) end do print *, end program main