Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import math
- def Suma(n):
- sum = 0.0
- for i in range (0,n):
- sum += (i + 1) / float(math.factorial(i))
- return sum * 0.5
- while True:
- try:
- err = input("err = ")
- err = float(err)
- if err < 0:
- print("Introduceti un numar pozitiv")
- else :
- n = 1
- sum = 0.0
- while True:
- sum = Suma(n)
- n += 1
- if(err >= math.e - sum):
- print(math.e - sum)
- break
- break
- except Exception as e:
- print(e)
- print("Introduceti un numar valid")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement