The formula
Equal temperament divides the octave into 12 identical ratios of 2^(1/12). Every note is therefore f = A4 × 2^(n/12), with n counted in semitones from A4. Going the other way, n = 12 × log₂(f ÷ A4), and whatever fraction of a semitone is left over is expressed in cents (hundredths of a semitone).
Want to hear any of these numbers? The tone generator plays arbitrary frequencies to 0.1 Hz precision - type the value in and listen.