The formula for the sample size for a mean is
For a proportion,the formula is
where p is derived from a previous study. If p is not known, then p = 0.5 is used in order to err on the side of caution.