In [25]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [3]:
from IPython.core.display import display,HTML,Math,Latex
In [4]:
#%%capture Catal
def Catalan(n):
    if n==0:
        return (1)
    else:
        return int(Catalan(n-1)*(4*n-2)/(n+1))
for n in range(11):
    display(Math("C_{"+str(n)+ "} = "+str(Catalan(n))))
$$C_{0} = 1$$
$$C_{1} = 1$$
$$C_{2} = 2$$
$$C_{3} = 5$$
$$C_{4} = 14$$
$$C_{5} = 42$$
$$C_{6} = 132$$
$$C_{7} = 429$$
$$C_{8} = 1430$$
$$C_{9} = 4862$$
$$C_{10} = 16796$$
In [10]:
y=""
for n in range(21):
    y=y+"C_{"+str(n)+ "} = "+str(Catalan(n))+"\\\\"
Math(y)
Out[10]:
$$C_{0} = 1\\C_{1} = 1\\C_{2} = 2\\C_{3} = 5\\C_{4} = 14\\C_{5} = 42\\C_{6} = 132\\C_{7} = 429\\C_{8} = 1430\\C_{9} = 4862\\C_{10} = 16796\\C_{11} = 58786\\C_{12} = 208012\\C_{13} = 742900\\C_{14} = 2674440\\C_{15} = 9694845\\C_{16} = 35357670\\C_{17} = 129644790\\C_{18} = 477638700\\C_{19} = 1767263190\\C_{20} = 6564120420\\$$
In [30]:
#Catal()
In [13]:
%store y > tester.txt
Writing 'y' (str) to file 'tester.txt'.
In [12]:
print(y)
C_{0} = 1\\C_{1} = 1\\C_{2} = 2\\C_{3} = 5\\C_{4} = 14\\C_{5} = 42\\C_{6} = 132\\C_{7} = 429\\C_{8} = 1430\\C_{9} = 4862\\C_{10} = 16796\\C_{11} = 58786\\C_{12} = 208012\\C_{13} = 742900\\C_{14} = 2674440\\C_{15} = 9694845\\C_{16} = 35357670\\C_{17} = 129644790\\C_{18} = 477638700\\C_{19} = 1767263190\\C_{20} = 6564120420\\
In [ ]: