Microsoft Small Basic

Program Listing: DNP836
' Calculate Napier's constant (the base of the natural logarithm)
' Version B
' Copyright © 2015 Nonki Takahashi. The MIT License.
' Last update 2015-06-19
' ln e = 1 (using bisection method)
e1 = 2
e2 = 3
Calc()
While ln <> 1
TextWindow.WriteLine("Math.NaturalLog(" + e + ")=" + ln)
If 1 < ln Then
e2 = e
Else
e1 = e
EndIf
Calc()
EndWhile
'e = 2.718281828459045235360287471352
TextWindow.WriteLine("Math.NaturalLog(" + e + ")=" + ln)
TextWindow.WriteLine("e=" + e)
Sub Calc
e = (e1 + e2) / 2
ln = Math.NaturalLog(e)
EndSub