generating pi to more than 2315 places
<p>I have managed to get my code working so it generates pi:</p>

<pre><code> while True:
        print("how many digits of pi would you like?")


        def make_pi():
            q, r, t, k, m, x = 1, 0, 1, 1, 3, 3
            for j in range(1000000):
                if 4 * q + r - t &lt; m * t:
                    yield m
                    q, r, t, k, m, x = 10 * q, 10 * (r - m * t), t, k, (10 * (3 * q + r)) // t - 10 * m, x
                else:
                    q, r, t, k, m, x = q * k, (2 * q + r) * x, t * x, k + 1, (q * (7 * k + 2) + r * x) // (t * x), x + 2


        digits = make_pi()
        pi_list = []
        my_array = []

        for i in make_pi():
            my_array.append(str(i))

        number = int(input())+2
        my_array = my_array[:1] + ['.'] + my_array[1:]
        big_string = "".join(my_array[: number ])
        print("here is the string:\n %s" % big_string)
</code></pre>

<p>however no matter how much I increase the <code>range</code> the code only outputs a maximum of 2315 digits of pi after the decimal point </p>

<pre><code>how can I fix this?
</code></pre>

<p>What about parametrizing that make_pi generator to accept the number of digits?</p>

<p>Something like this:</p>

<pre><code>def make_pi(num_digits):
    q, r, t, k, m, x = 1, 0, 1, 1, 3, 3
    for j in range(num_digits):
        if 4 * q + r - t &lt; m * t:
            yield m
            q, r, t, k, m, x = 10 * q, 10 * \
                (r - m * t), t, k, (10 * (3 * q + r)) // t - 10 * m, x
        else:
            q, r, t, k, m, x = q * \
                k, (2 * q + r) * x, t * x, k + \
                1, (q * (7 * k + 2) + r * x) // (t * x), x + 2


num_digits = 10000
pi = "".join([str(d) for d in make_pi(num_digits)])
print("{0}.{1}".format(pi[:1], pi[1:]))
</code></pre>

python python-3.x pi