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
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,
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,
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