Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # paulogp
- def factorial(n):
- '''Retorna o factorial de n'''
- f = 1
- while (n > 0):
- f = f * n
- n = n - 1
- return f
- def neper(x, n):
- '''
- Retorna e^x
- e^0 = 1
- e^1 = 2.71828182846
- e^2 = 7.38905609893
- x - potencia (float)
- n - Numero de iteracoes
- PS: e^1 = (1+(1/n))^n
- '''
- f = 0.0e10
- for i in range(0, n):
- f = f + ( x**i / factorial(i) )
- print f
- # Exemplo
- neper(1.0, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement