Task

Calculate the value of   e.



(e   is also known as   Euler's number   and   Napier's constant.)



See details: Calculating the value of e

INCLUDE "H6:REALMATH.ACT"
 
PROC Euler(REAL POINTER e)
  REAL e0,fact,tmp,tmp2,one
  INT n
 
  IntToReal(1,one)
  IntToReal(2,e)
  IntToReal(1,fact)
  n=2
 
  DO
    RealAssign(e,e0)
    IntToReal(n,tmp)
    RealMult(fact,tmp,tmp2)
    RealAssign(tmp2,fact)
    n==+1
    RealDiv(one,fact,tmp)
    RealAdd(e,tmp,tmp2)
    RealAssign(tmp2,e)
  UNTIL RealGreaterOrEqual(e0,e)
  OD
RETURN
 
PROC Main()
  REAL e,calc,diff
 
  Put(125) PutE() ;clear screen
  ValR("2.71828183",e)
  Euler(calc)
  RealSub(calc,e,diff)
  Print("      real e=") PrintRE(e)
  Print("calculated e=") PrintRE(calc)
  Print("       error=") PrintRE(diff)
RETURN