Minimal cyclotomic field containing a given quadratic field? There was an exercise labeled difficile (English: difficult) in the material without solution:

Suppose $d\in\mathbb Z\backslash\{0,1\}$ without square factors, and $n$ is the smallest natural number $n$ such that $\sqrt d\in\mathbb Q(\zeta_n)$, where $\zeta_n=\exp(2i\pi/n)$. Show that $n=\lvert d\rvert$ if $d\equiv1\pmod4$ and $n=4\lvert d\rvert$ if $d\not\equiv1\pmod4$.

It's easier to show that $\sqrt d\in\mathbb Q(\zeta_n)$, although I haven't worked out every epsilon and delta: First we can factor $d$ as a product of unit and prime numbers. Note that a quadratic Gauss sum $g(1,p)=\sum_{m=0}^{p-1}\zeta_p^{m^2}=\sqrt{(-1)^{(p-1)/2}p}\in\mathbb Q(\zeta_p)$, and that $\sqrt2\in\mathbb Q(\zeta_8)$. From this we can deduce that $\sqrt d\in\mathbb Q(\zeta_n)$, where $n=\lvert d\rvert$ if $d\equiv1\pmod4$ or $4\lvert d\rvert$ otherwise.
I have no idea how to show that $n$ is minimal. I hope we'll have some proof without algebraic number theory, which is all Greek to me.
Any help is welcome. Thanks!

I don't think that your answer to @JyrkiLahtonen could give the solution because, once again, how do you  deal with the minimality problem ? Jyrki's hint at the discriminant is the right one... provided you appeal to CFT, here the Kronecker-Weber theorem since the base field is $\mathbf Q$: every abelian extension $K/\mathbf Q$ is contained in a cyclotomic field $\mathbf Q (\zeta_n)$, and the minimal such $n$ is called the conductor of $K$. For a quadratic field $K = \mathbf Q (\sqrt d)$, the conductor of $K$ is the absolute value of the discriminant, which is $d$ if $d \equiv 1 mod 4$, or $4d$ otherwise. This is a theorem. It is weird that this difficile exercise is given without at least a reference to ANT (ramification).
