'+---------------------------------------------------+
'|  E U C L I D  -- Demonstrates Euclid's Algorithm  |
'+---------------------------------------------------+

  locate 10,1
  print "Demonstrating the Euclid Algorithm"
  do
    gosub [ClrLine3]
    input "Enter first integer = "; first
    if abs(int(first)) > 99999999 then first = 0
  if first <> abs(int(first)) then first = 0
  loop until first <> 0
  locate 1,6 : print using ("########", first)
  do
    gosub [ClrLine3]
    input "Enter second integer = "; second
    if abs(int(second)) > 99999999 then second = 0
  if second <> abs(int(second)) then second = 0
  loop until second <> 0
  gosub [ClrLine3]
  product = first * second
  if first < second then
    x = first : first = second : second = x
  end if

  cls
  locate 10,1
  print "Demonstrating the Euclid Algorithm"
  locate 11,3
  print "first = "; using ("########", first)
  locate 10,4
  print "second = "; using ("########", second)
  locate 1,6 : print using ("########", first);
  print "        dividend       remainder"
  locate 1,7 : print using("########", second);

  do
    quotamt = int(first / second)
    remamt = first - quotamt * second
    print using ("################", quotamt);
    print using ("################", remamt)
    HCF = second : first = second : second = remamt
    if second > 0 then
      print using ("########", second);
    end if
  loop until second = 0
  print
  print using("################",HCF);" = HCF"
  product = product / HCF
  print using("################",product); " = LCM"
  stop

'+----------------------------------------+
'|                                        |
'|   L O C A L   S U B R O U T I N E S    |
'|   =================================    |
'|                                        |
'+----------------------------------------+
'| [ClrLine3]                             |
'|                                        |
'|    Clear line 3                        |
'+----------------------------------------+
[ClrLine3]

  locate 1,3 : print space$(100)
  print "          (1-8 digits + Enter)"
  locate 1,3
  return















