Prove that every ideal of a Euclidean domain is principal 
Prove that every ideal of a Euclidean domain is principal.

I'm new to algebra, so the solution below is probably really awkward and unconcise. 
So I was given the hint that I should let $I$ be an ideal and consider when $I= \{0\}$ and when $I\neq \{0\}.$ Obviously, $I=\{0\}=\langle 0\rangle$ is principal. As for $I\neq \{0\},$ I think I need to think of the smallest/minimal nonzero element, say $a$, in $I$ and show that $I=\langle a\rangle.$ As well, I know that an integral domain $D$ is a Euclidean domain iff for all $a,b\in D,$ $a=bq+r,$ where $b\neq 0,$ and $r=0$ or $N(r)<N(b),$ where $N(r)$ denotes the norm of $r.$ That is, from my understanding, $N(r)$ is the function $N : R \to \mathbb{N}\cup \{0\}$ such that $N(0)=0$ (am I forgetting anything here?) I just need to show that $\forall x\in I\Leftrightarrow x\in \langle a\rangle.$ Let $x,y\in I$ and $r=x-ya.$ If $r=0,$ we are done. If $r\neq 0,$ then by the well-ordering principle, there is a minimum value of $r,$ say $r_1.$ But $a$ is the minimum value of $I,$ so $r_1<a,$ which means that $r_1$ must be zero and thus $I=\langle a\rangle.$ I think I'm missing something here.
 A: The argument is generally okay (it proceeds along the usual lines), but with some small errors. 
You should not write $\langle a\rangle = \{r_1a, r_2a,\ldots, r_na\mid r_i\in R\}$, because that implies that $R$ is finite. Rather, you should write $\langle a \rangle = \{ra\mid r\in R\}$. 
(This holds in this case because we are assuming that $R$ is commutative and has a unit; if either of those things does not hold, the description of the principal ideal generated by $a$ is slightly more complicated).
The way you wrote the Euclidean property is also not quite right. Rather, the condition that $b\neq 0$ precedes the equation: if $b\neq 0$, then for all $a$ there exists $q,r\in D$ such that $a=qb+r$ and $r=0$ or $N(r)\lt N(b)$. (Of course, you also need the existence of the function $N$...)
In general you do not require $N(0)=0$; for example, the degree function on $\mathbb{R}[x]$ makes the ring $\mathbb{R}[x]$ into a polynomial ring, but we do not have that the $0$ polynomial has degree $0$; the degree is usually either undefined or called "$-\infty$". The Euclidean function is required to be defined only on $D-\{0\}$. The defining property of $N$ is that if $ab\neq 0$ and $b\neq 0$, then $N(ab)\geq N(b)$, and that the division algorithm holds.
You can't compare $r_1$ with $a$: $a$ is in $R$, whereas $r_1$ is an integer. Rather, you should have that you cannot have $r_1\lt N(a)$. That is what implies that $r_1=0$. But in any case, your derivation of $r_1$ doesn't work.
You want to show that $I\subseteq \langle a\rangle$. So let $x\in I$. Then, because $a\neq 0$, there exists $q,r\in R$ such that $x=aq+r$ and either $r=0$ or $N(r)\lt N(a)$. Since $a$ is chosen from among all elements of $I$ so that $N(a)$ is minimal, we cannot have $N(r)\lt N(a)$. So that means that $r=0$, and hence $x=aq\in\langle a\rangle$. 
