Calculating pairwise Fst from allele frequencies
The original Wright's formulation
$$Fst=\frac{var(p)}{\bar p}$$
, where $\bar p = \frac{1}{J} \sum_{j=1}^J p_{j}$ and $var(p) = \frac{1}{J}\sum_{j=0}^J (p-\bar p)^2$ is the variance in frequencies among populations.
This original formulation is valid only for a bi-allelic locus. Nei (1973) generalizes this definition to loci that have more than two alleles.
Nei (1973) general formulation
I recommend to have a look a the paper (Nei 1973), it is a really nice paper.
Nei shows that defining that within Subpopulation gene diversity (a.k.a. expected heterozygosity) $H_S$ and the Total gene diversity (a.k.a. expected heterozygosity) $H_T$ as
$$H_S = \frac{1}{J}\sum_{j=1}^J \frac{1}{I}\sum_{i=1}^I p_{ij}^2$$
$$H_T = \frac{1}{I}\sum_{i=1}^I \left(\frac{1}{J} \sum_{j=1}^J p_{ij}\right)^2$$
, where $I$ is the number of alleles and $J$ is the number of populations. Then Wright's definition of $F_{ST}$
$$F_{ST} = \frac{var(p)}{p(1-p)}$$
generalizes (for cases with more than one allele) into
$$Fst = \frac{H_T-H_S}{H_T}$$
Have a look at Nei 1973 to understand why they are equivalent.
Weir and Cockerham (1984) formulation for several loci
Averaging $Fst$ over several loci is more complicated than one would expect at first place. The solution is given in Weir and Cockerham 1984.
The formulation is a little cumbersome so I just invite you to have a look at the paper.