Fourier series in $$\text {BMO}$$ with number theoretical implications