Algorithms

Possibly one of the coolest and simplest algorithms of all time. An easy way to find the greatest common divisor (GCD) of two numbers. This algorithm was discovered/created by Euclid and presented as a proposition in his Elements book.

5 REM Euclid's algorithm for greatest common divisor
  6 PRINT "Type two integers greater than 0"
  10 INPUT A,B
  20 IF B=0 THEN GOTO 80
  30 IF A > B THEN GOTO 60
  40 LET B=B-A
  50 GOTO 20
  60 LET A=A-B
  70 GOTO 20
  80 PRINT A
  90 END
Published
Categorized as Coding