I'm new to Python. This is a homework problem, but it is tough as I only have a little experience in Java. The code is supposed to print the first Catalan-numbers using its recursive definition:
C(n + 1) = C(n) * (4n + 2) / (n + 2)
EDIT:
My current code looks like this, and the only remaining problem is to put all the C(n) numbers I get by this code in a txt using the savetxt() method.
import numpy
c = []
c.append(1)
for i in xrange(0,1000000000):
c.append((4*i+2)*c[i]/(i+2))
print (c[i])
if c[i]>= 1000000000:
break
numpy.savetxt("catalan",numpy.c_[i, c[i]])
After this last problem is solved, I will try some other versions suggested in the answers (like filling up an array of zeroes first).