English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Pseudo code for the Euclid's algoritm fo finding the gcd(m,n) using subtraction........

2007-12-23 13:30:24 · 2 answers · asked by Ammu 2 in Science & Mathematics Mathematics

2 answers

function gcd(a, b)
 while b ≠ 0
  if a > b
   a := a - b
  else
   b := b - a
 return a

2007-12-23 13:40:54 · answer #1 · answered by jgoulden 7 · 0 0

Let the variable be U and V

1. Read u and v
2. If v>u then interchange values
3. Do until v <= 0
a. u = u - v
b. If v .> u then interchange values
c. Continue
4. Answer on u

2007-12-23 22:04:37 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers