Total capacitance for a ladder network with two capacitances
For each segment, we have two capacitors in series which are then in parallel with a third, so we have a total capacitance of:

$$C_{leg} = C_1 + \frac{1}{\frac{1}{C_2} + \frac{1}{C_1}}$$

We can generalise this into an iterative formula for each leg if we assume that the leg consists of only the two capacitors, and the final leg consists of just \$C_1\$:

$$C_{leg}(m+1) = C_1 +  \frac{1}{\frac{1}{C_2} + \frac{1}{C_{leg}(m)}} \quad\quad\quad\mathrm{where}\quad C_{leg}(0)=C_1$$

You can then simply iterate the formula \$n\$ times until you have the total capacitance - i.e. \$C_{total} = C_{leg}(n)\$.



Just for the fun of it, you will essentially you end up calculating iteratively something like this (example for n=4):

$$C_{total} = C_1 + \cfrac{1}{\frac{1}{C_2} + \cfrac{1}{C_1
          + \cfrac{1}{\frac{1}{C_2} + \cfrac{1}{C_1
          + \cfrac{1}{\frac{1}{C_2} + \cfrac{1}{C_1 + \cfrac{1}{\frac{1}{C_2} + \frac{1}{C_1}}}}}}}}$$