Advertisement
nikol_bratkova

Untitled

Mar 23rd, 2022
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from math import factorial
  2.  
  3.  
  4. n = int(input())
  5. x = float(input())
  6.  
  7.  
  8. s = 1
  9. k = 1
  10. factorial = 1
  11.  
  12. for i in range(1, n + 1):
  13. factorial = factorial*i
  14. s = s + (factorial / x ** k)
  15. k = k + 1
  16. if k == n + 1:
  17. break
  18.  
  19. s = '{:.5f}'.format(s)
  20. print(s)
Advertisement
RAW Paste Data Copied
Advertisement