The natural number represented by the letter e; make it posible to calculate, at leats with an approximation desired; that is what the WSQ14 asks me to do.
So what I have to do is to make a program that calculates the value of e given an aproximation that the user inputs.
The value of e is define by the limit of the following formula when n is reaching the infinity
(1 + 1/n)^n
Because the formula is defined and is already tested, to do the code is pretty easy.
Just had to put the formula, keep aumenting the value of n one by one, and I will stop untill I met the estimation the user wanted.
That last part is achieved by comparing the absolute diference between the previos result and the current one with the estimation, if it is bigger, then I will have to keep doing the calculations.
Here is that part
So we start limit and oldlimit in a way that the diference will be greater than one
Then we equal the oldlimit to the limit in order to save the value, and asing to limit the value of the applicated formula in the terms of n, we add n 1, and keep doing it until we get to the estimation
So the coding was really easy, only because of Euler
As always:
WSQ14: e number by charliegdrummer is licensed under a Creative Commons Attribution 4.0 International License.