calculate catalan numbers up to a billion
<p>I'm new to python (and programming in general), I was asked in my class to calculate Catalan numbers up to a billion but the program I wrote for it is not working as intended.</p>

<pre><code>    from numpy import division 
    C=1
    n=0
    while C&lt;=10000000000:
        print (C)
        C=(4*n+2)/(n+2)*C
        n=n+1
</code></pre>

<p>This is what it prints</p>

<p>1,
1,
2,
4,
8,
24,
72,
216,
648,
1944,
5832,
17496,
52488,
157464,
472392,
1417176,
4251528,
12754584,
38263752,
114791256,
344373768,
1033121304,
3099363912,
9298091736,</p>

<p>As you can see from my fourth iteration onwards, I get the wrong number and I don't understand why.</p>

<p>EDIT:
The mathematical definition I used is not wrong! I know the Wiki has another definition but this one is not wrong.
Co=1, Cn+1 = (4*n+2)/(n+2)*Cn</p>

<p>Based on this expression for <a href="https://en.wikipedia.org/wiki/Catalan_number" rel="nofollow">Catalan Numbers</a>:</p>

<p><a href="http://i.stack.imgur.com/sfa7X.png" rel="nofollow"><img src="http://i.stack.imgur.com/sfa7X.png" alt="enter image description here"></a></p>

<pre><code>from math import factorial

C = 1
n = 0
while C &lt;= 10000000000:
    print(C)
    C = (factorial(2 * n)) / (factorial(n + 1) * factorial(n))
    n = n + 1
</code></pre>

<p><strong>Returns:</strong></p>

<pre><code>1
1.0
1.0
2.0
5.0
14.0
42.0
132.0
429.0
1430.0
4862.0
16796.0
58786.0
208012.0
742900.0
2674440.0
9694845.0
35357670.0
129644790.0
477638700.0
1767263190.0
6564120420.0
</code></pre>

python