Fourier series in BMO with number theoretical implications