Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The greatest common divisor of two numbers
#2
Hi Petr,

There are much simpler ways to do GCD:
https://rosettacode.org/wiki/Greatest_co...isor#BASIC

my favorite:
Code: (Select All)
_Title "GCD = Greatest Common Denominator" ' b+ 2020-05-21 from SB

While 1
    Input "enter a, b or 0 to quit "; a, b
    If a <> 0 And b <> 0 Then Print GCD(a, b) Else End
Wend

Function GCD (a As _Integer64, b As _Integer64)
    While a <> 0 And b <> 0
        If a > b Then a = a Mod b Else b = b Mod a
    Wend
    GCD = a + b
End Function
b = b + ...
Reply


Messages In This Thread
RE: The greatest common divisor of two numbers - by bplus - 11-04-2024, 10:16 PM



Users browsing this thread: 1 Guest(s)