By Alvin Alexander. Last updated: June 4, 2016
Still reading Calculus Made Easy, they note that 'e' (the natural logarithm, or natural log) is the limit of the following series:
1 + 1/1! + 1/2! + 1/3! ...
To test this I created the following Ruby natural log program.
# a program to calculate 'e' using ruby.
# 'e' is the limit of this series:
# 1 + 1/1! + 1/2! + 1/3! ...
# determine the factorial value of a given number
def factorial(num)
total=1
for i in (1..num)
total = total * i
end
total
end
e = 1.0
for den in (1..20)
e = e + 1.0/factorial(den)
end
puts "e = #{e}"

