That really depends upon the compound. Since you have not described the compound in any way, there would be no way to work out the formula. Other than that, you are always guided by the Periodic Table of elements and your knowledge of the valences of the elements; you should be familiar with common radicals, and with various organic compounds which might be part of a formula. The more you know about chemistry, the better chance you will have of working out a given formula.
C7H14O is the formula for the compound.
The compound formula for potassium iodide is KI.
The formula of a compound with the smallest ratios is called the empirical formula. It represents the simplest whole-number ratio of atoms in a compound.
The empirical formula is representative for the chemical composition of a compound; the structural formula is representative for the spatial structure of the compound.
The compound with the formula TiBr3 is titanium(III) bromide.
The compound formula for silver hydride is AgH.
This is the chemical formula (empirical formula) or the formula unit of this compound.
C7H14O is the formula for the compound.
The compound formula for silver hydride is AgH.
The compound formula of sodium phosphite is Na3PO3.
The compound formula for potassium iodide is KI.
The compound formula for phosphorus tribromide is PBr3.
The compound formula for silver phosphide is Ag3P.
The compound formula for tricarbon octahydride is C3H6.
The compound formula for silver hydroxide is AgOH.
There is no carrot in the compound interest formula!
The compound formula for aluminum phosphate is AlPO4.