Predicting molecular geometry from a formula
It will depend on the number of lone electron pairs as well.
For example:
$BCl_3$ will be triangular planar as it has no lone electron pairs.
$NH_3$ however will be triangular based-pyramidal because there are 3 bonded pairs of electrons and one lone electron pair.
Basically, it comes down to the number of electron pairs (both bonded and unbonded) around the central atom.

Two electron pairs - Linear


Three electron pairs - Triangular planar


Four electron pairs - Tetrahedral


Five electron pairs - Triangular based bi-pyramidal (it's like triangular planar, but with one on top and one below, or two triangular pyramids with their base stuck together)


Six electron pairs - Octahedral (Square based bi-pyramidal)



Those geometries include the lone electron pairs. For the molecular geometry, you will then need to exclude the electron pair.
E.g. $H_2O$ : central atom O. O has 4 electron pairs: 2 bonded, 2 lone. The shape, including lone electron pairs is Tetrahedral. Ignore the lone pairs now, you will be left with a bent molecular geometry.

Blue is oxygen;
Yellow is hydrogen;
White/Grey are lone/unbonded electron pairs.
I hope this makes sense. :)