#QUIZ 04 – Euler

1. The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828,[1] and is the limit of (1 + 1/n)n as n approaches infinity, an expression that arises in the study of compound interest. It can also be calculated as the sum of the infinite series.

e =  displaystylesumlimits_{n = 0}^{ infty} dfrac{1}{n!} = 1 + frac{1}{1} + frac{1}{1cdot 2} + frac{1}{1cdot 2cdot 3} + cdots

Source: https://en.wikipedia.org/wiki/E_(mathematical_constant

Create a function called euler_calc with a single parameter precision. The value of precision is used to determine when to stop calculating. Your calculation will stop when the two consecutive values estimating e differ by less than precision (remember to use absolute value when calculating the difference between two values here).

2016-04-02 (9)2016-04-02 (6)

En este programa cree una función que se encarga de realizar el proceso para el numero de Euler, el programa recibe un valor dado por el usuario, este sera la cantidad de decimales que tendrá la respuesta, tantos decimales como pide el usuario es la exactitud del numero.

Como primer paso pedí el valor al usuario, después se definí la función, agregue el parámetro que debía recibir y lo empece a utilizar, al inicio con un pequeño ciclo que se encarga de detener el proceso del numero de Euler, luego agregue la función factorial de acuerdo al numero que va almacenando un contador y con otro contador se guarda el numero uno sobre su factorial según el numero de intentos, al final solo se imprimen los resultados.

CC BY-SA 4.0 #QUIZ 04 – Euler by valeriananc is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.