Determining the formula of a compound