fork(1) download
  1. epsi = 0.0001
  2. term = 1
  3. sum = 1
  4. def fact (n):
  5. prod = 1
  6. if n == 0:
  7. return 1
  8. else:
  9. for i in range (n):
  10. prod *= (i+1)
  11. return prod
  12. x = float(input())
  13. k = 1
  14. while term > epsi:
  15. term = (x**k)/fact(k)
  16. sum += term
  17. k += 1
  18. print sum
Success #stdin #stdout 0.01s 7536KB
stdin
-1
stdout
0.0