3
01 Greatest Common Divisors
Given two natural numbers, and , the greatest common divisor may be found using
Euclid’s algorithm. A simplified explanation is given below:
1.Let and be two natural numbers.
2.Let be the remainder after dividing by .
3.If , set and and return to 2.
4.If =
0 , then is the greatest common divisor.
Program
Lbl 1:?→ A:?→ B:B > A ⇒ Goto 1:Lbl 2:A - B → A:A ≧ B
⇒ Goto 2:A =0⇒ Goto 3:A → C:B → A:C → B:Goto 2:Lbl
3:B < 60 STEP >
Execution Example:
Find the greatest common divisor of 210 and 60.
AB
Greatest common divisor
AB AB>()
CAB
C 0≠ BA→ CB→
CB
ON
MODE MODE MODE
1
PRGM
MODE
1
COMP
1
P1
Prog
1
S A
D R
P1
P2 P3 P4
G
210
EXE
S A
D R
P1
P2 P3 P4
G
60
EXE
S A
D R
P1
P2 P3 P4
G
関数電卓事例集 .book 3 ページ 2002年9月2日 月曜日 午後6時51分