11-05-2024, 01:39 PM
(11-04-2024, 10:16 PM)bplus Wrote: 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
I just came and looking. Well, that's a beautiful example of how to do the same thing easily or complicatedly. And me (traditionally) chose the harder way Thanks for your version, BPlus.