%%%%%%%%%%%%%%% algorithme d'Euclide

\newcount\@quotient
\newcommand\algoeuclide[2]{%
	Calculons \pgcd{#1}{#2} à l'aide de l'algorithme d'Euclide.\def\varA{#1}\def\varB{#2}\par\begin{quote}
   \ifnum#2>#1
      \def\next{\@lgeuclide{#2}{#1}}%
   \else
      \def\next{\@lgeuclide{#1}{#2}}
   \fi\next}
   
\newcommand\@lgeuclide[2]{%
   \ifnum#2>\z@
      \@quotient#1
      \divide\@quotient#2
      \edef\next{\number\numexpr#1-\@quotient*#2}%
      $#1=\number\@quotient\times#2+\next$\par 
      \edef\next{\noexpand\@lgeuclide{#2}{\next}}%
      \expandafter\next
   \else
      	\end{quote}\smallbreak \underline{On en déduit que $\pgcd{\varA}{\varB}=#1$.}%
   \fi}
