PROGRAM Exponential
   IMPLICIT NONE
 
   INTEGER         :: Count
   REAL            :: Term, Sum, Number , ExpNum, Initial, Final, Step
   REAL, PARAMETER :: Tolerance = 0.00001

   WRITE(*,*) 'Initial, final and step please ---> '
   READ(*,*) Initial, Final, Step

   Number = Initial
  
   DO
      IF ( Number > Final ) EXIT
      Count = 1 
      Sum = 1.0
      Term = Number
      ExpNum = EXP(Number)
   
      DO
         IF ( ABS(Term) < Tolerance ) EXIT
         Sum   = Sum + Term
         Count = Count + 1
         Term  = Term * ( Number / Count ) 
      END DO

      WRITE(*,*) 'After ', Count, ' iterations:'
      WRITE(*,*) '  EXP(', Number, ') = ', Sum
      WRITE(*,*) '  From EXP()     = ', ExpNum
      WRITE(*,*) '  ABS(error)     = ', ABS( Sum - ExpNum)
      WRITE(*,*) 
      Number = Number + Step
   END DO

END PROGRAM Exponential
