Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. def calc_pi(acc):
  2. pos = False
  3. sum = 4.0
  4. for i in range(2, acc):
  5. if not pos:
  6. sum -= 4.0/(2*i-1)
  7. pos = True
  8. else:
  9. sum += 4.0/(2*i-1)
  10. pos = False
  11. return float(sum)
  12.  
  13. print(calc_pi(5000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement