Counting number of ideals in quadratic number field Let $K$ be a quadratic number field and $R$ be its number ring, and if $a(n)$ denotes number of ideals of norm $n$, if $n$ is a prime number, then number of ideals of norm $n$ is $1+(d|n)$, where $d$ is the discriminant of $K$ and $(d|n)$ is Legendre-Jacobi-Kronecker symbol. I wantn to find the number of ideals of norm $p^m$ where $p$ is a prime and $m$ is natural number greater than $1$.
 A: To avoid misunderstanding, I first reprove your assertion in the case $n=$ a prime $p$ (excluding the particular case $p=2$). A rational odd prime $p$ decomposes in a quadratic field $K$ of discriminant $D$ in 3 possible manners : (i) $p \mid D, p$ is totally ramified, i.e.  $(p)=P^2, N(P)=p$ ; (ii) $p \nmid D$, and $(\frac Dp)=1$ iff $p$ splits, i.e. $(p)=P.P', N(P)=N(P')=p$ ; (iii) $p \nmid D$, and $(\frac D p)=-1$ iff $p$ is inert, i.e. $(p)=P^2, N(P)=p^2$ . Considering these 3 cases, as well as the uniqueness of prime factorization in a Dedekind ring, one gets immediately that the number $a(p)$ of ideals of norm $p$ is $1$ if $p \mid D$, resp. $1+(\frac Dp)$ if $p \nmid D$ .
The calculation of $a(p^m)$ proceeds exactly in the same way because of the uniqueness of prime decomposition : if you have a prime decomposition of $(p)$, then you get a prime decomposition of $(p^m)$, and uniqueness tells you that this is the only possible decomposition of $(p^m)$. Examining the 3 cases and recalling that the norm of ideals is a multiplicative function, you get that $a(p^m)=a(p)$ in the first 2 cases since $N(P^m)=p^m$. In the 3-rd case, you have $(p^{2k})=P^{4k}, N(P^k)=p^{2k}$ and $a(p^{2k})=1$, whereas $a(p^{2k+1})=0$ obviously.
