Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import cycle, imap, izip, count, islice
- n = 5000000
- ones = cycle([1, -1])
- odds = count(1, 2)
- fracs = imap(lambda x: 1.0 / (x[0] * x[1]), izip(ones, odds))
- print sum(islice(fracs, n)) * 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement