      program main
      double precision x, y, yn, yexact, h
      double precision f, sol
      integer i, n
      write(6,*) 'y0 ='
      read (5,*) y
      write(6,*) 'n ='
      read (5,*) n
      h=1.0d0/dble(n)
      do i=0, n-1
         x=dble(i)*h
         yn=y+h*f(x,y)
         yexact=sol(x+h)
         write(6,*) x+h, yn, yexact, abs(yn-yexact)
         y=yn 
      end do 
      stop
      end
C
      double precision function f(x,y)
      double precision x, y
      f=x+y+1.0d0
      return
      end
C
      double precision function sol(x)
      double precision x
      sol=-x+exp(x)-2.0d0
      return
      end