Skip to main content

Теория: Алгоритм Евклида

Задание

С помощью алгоритма Евклида найдите наибольший общий делитель чисел \(\displaystyle 17\) и \(\displaystyle 18{\small .}\)

\(\displaystyle \text{НОД}(17, 18) = \)

Решение

Алгоритм

Алгоритм Евклида для НОД(a, b)

1. Пусть \(\displaystyle b>a{\small .}\) Делим большее \(\displaystyle b\) на меньшее \(\displaystyle a\) с остатком:

\(\displaystyle b=a\cdot n+ {\bf r}{\small .}\)

2. \(\displaystyle \text{НОД}(a,b)=\text{НОД}(a,{\bf r}){\small .}\)

3. Если \(\displaystyle {\bf r}=0{\small ,}\) то \(\displaystyle \text{НОД}(a,{\bf r})=a{\small .}\) Если \(\displaystyle {\bf r}=\not 0{\small ,}\) то ищем \(\displaystyle \text{НОД}(a,{\bf r})\) (но теперь \(\displaystyle a>{\bf r}\)).

 

Шаг 1. Применим алгоритм Евклида к \(\displaystyle \text{НОД}(17, 18){\small .}\)

1. Так как \(\displaystyle 18> 17\), то делим \(\displaystyle 18\) на \(\displaystyle 17\) с остатком: \(\displaystyle 18=17\cdot 1+{\bf 1}{\small .}\)

2. \(\displaystyle \text{НОД}(17,18)=\text{НОД}(17,{\bf 1}){\small .}\)

3. Так как \(\displaystyle {\bf 1} =\not 0{\small ,}\) то переходим к шагу 2.

 

Шаг 2. Применим алгоритм Евклида к \(\displaystyle \text{НОД}(17, 1)=\text{НОД}(1, 17){\small .}\)

1. Так как \(\displaystyle 17> 1{\small ,}\) то делим \(\displaystyle 17\) на \(\displaystyle 1\) с остатком: \(\displaystyle 17=17\cdot 1+{\bf 0}{\small .}\)

2. \(\displaystyle \text{НОД}(1,17)=\text{НОД}(1,{\bf 0}){\small .}\)

3. \(\displaystyle \text{НОД}(1,{\bf 0})=1{\small .}\)

 

Ответ: \(\displaystyle \text{НОД}(17, 18)=1{\small .}\)