Microsoft Small Basic

Program Listing: CML298-1
' Calculate Napier's constant (the base of the natural logarithm)
' Version A3
' Copyright © 2015-2017 Nonki Takahashi. The MIT License.
' Last update 2017-03-04
' Program ID CML298-1
' e = Σ(n=0..∞) 1/n!
f = 1 ' 0!
e = 1 / f
For n = 1 To 27
f = f * n ' overflow exception occurs if f = 28!
e = e + 1 / f
EndFor
TextWindow.WriteLine("e = " + e)
TextWindow.WriteLine("ln(e) = " + Math.NaturalLog(e))