Advertisement
Guest User

Untitled

a guest
Aug 29th, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. from itertools import cycle, imap, izip, count, islice
  2.  
  3. n = 5000000
  4. ones = cycle([1, -1])
  5. odds = count(1, 2)
  6. fracs = imap(lambda x: 1.0 / (x[0] * x[1]), izip(ones, odds))
  7.  
  8. print sum(islice(fracs, n)) * 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement