You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
388B

  1. def euclid ( a, b )
  2. begin
  3. if a < 0 then a := -a
  4. if b < 0 then b := -b
  5. if gcd ( a, b ) > 1 then
  6. print "Greatest common divisor of", a, "and", b, "is", gcd ( a, b )
  7. else
  8. print a, "and", b, "are relative primes"
  9. return 0
  10. end
  11. def gcd( a, b )
  12. begin
  13. var g
  14. if b > 0 then
  15. g := gcd ( b, a - ((a/b)*b) )
  16. else
  17. g := a
  18. return g
  19. end