Re: [Edu-sig] Edu-sig Digest, Vol 113, Issue 9

2012-12-23 Thread Marianne McKenna
I will be out of the office for the holiday break. I will be checking email periodically and will respond as soon as I can. If you need immediate help please contact the computer center. Thanks. ___ Edu-sig mailing list Edu-sig@python.org

Re: [Edu-sig] generate digits of pi

2012-12-23 Thread michel paul
I realized something. This was the original version: def pi_digits(): k, a, b, a1, b1 = 2, 4, 1, 12, 4 while True: p, q, k = k*k, 2*k+1, k+1 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 d, d1 = a/b, a1/b1 while d == d1: yield int(d) a,

Re: [Edu-sig] generate digits of pi

2012-12-23 Thread kirby urner
Right, there's like a stutter in the inner while loop where it sometimes spits out more digits before getting back to the outer loop, so sometimes you get one or two more digits than requested. That doesn't mean I understand the algorithm, i.e. why d == d1 is critical. Kirby On Sun, Dec 23,

Re: [Edu-sig] generate digits of pi

2012-12-23 Thread Litvin
Or just replace while d == d1: with while d == d1 and n 0: Gary Litvin www.skylit.com At 11:54 PM 12/23/2012, da...@handysoftware.com wrote: Here's an easier, pythonic way to limit the number of digits, given the original, non-terminating pi generator: import itertools