Guest User

Untitled

a guest
Jan 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. def oddnumbers():
  2. n = 1
  3. while True:
  4. yield n
  5. n += 2
  6.  
  7. def pi_series():
  8. odds = oddnumbers()
  9. approximation = 0
  10. while True:
  11. approximation += (4 / next(odds))
  12. yield approximation
  13. approximation -= (4 / next(odds))
  14. yield approximation
  15.  
  16.  
  17. approx_pi = pi_series()
  18.  
  19. for i in range(1000):
  20. print(next(approx_pi))
Add Comment
Please, Sign In to add comment