c   4.$B<+A3BP?t$NDl(B
c     $B?9@n(B $BLwBg(B  , 22980138
c      
      program ex4
c
      implicit none      
      integer :: i
      integer(8) ::fact
      real(4) :: ee(30),eea(30),eelog(30)
      real(8) :: ed(30),eda(30),edlog(30),d

c-----$B<+A3BP?t$NDl$N??CM(B
      d=dexp(1.0d0)

       ee(1)=1.0e0
       ed(1)=1.0d0
       do i=2,30
c---------$B<+A3BP?t$NCM(B
c-------------(dble $B$OG\@:EY<B?t2=$N5-9f(B)
          ee(i)=ee(i-1)+1.0e0/float(fact(i-1))
          ed(i)=ed(i-1)+1.0d0/dble(fact(i-1))
c---------$B@dBP8m:9(B          
          eea(i)=abs(d-ee(i))
          eda(i)=abs(d-ed(i))
c---------$BAjBP8m:9(B       
c          eer(i)=eea(i)/real(d)
c          edr(i)=eda(i)/d
       enddo
c------$B@dBP8m:9$N<+A3BP?t$NCM(B($B%0%i%UMQ(B)
       do i=2,17
          eelog(i)=log(abs(eea(i)))
          edlog(i)=dlog(abs(eda(i)))
       enddo
       do i=2,17
           write(10,*) i,eelog(i)
       enddo
       do i=2,17
           write(11,*) i,edlog(i)
       enddo

      stop
      end

c-----$B3,>h$N4X?t(B
      function fact(x)
       implicit none
       integer :: j
       integer(8) :: fact
       integer,intent(in) :: x
       fact=1
        do j=1,x
           fact=fact*j
        enddo
      return
      end
