faqts : Computers : Programming : Languages : Bbcbasic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

BBCBASIC: Windows: Mathematics: How to calculate the greatest common divisor? Recursively

Apr 26th, 2006 11:34
Knud van Eeden,


REM library: greatest: common: divisor: recursive 
(filenamemacro=commgrdr.bbc) [kn, amv, we, 26-04-2006 18:18:59]

DEF FNGreatestCommonDivisorRecursive( number1I%, number2I% )

 REM e.g. REM goal: determine of 2 numbers

 REM e.g. REM

 REM e.g. REM The greatest common divisor

 REM e.g. :

 REM e.g. PRINT FNGreatestCommonDivisorRecursive( 10, 20 ) : REM gives 
10

 REM e.g. PRINT FNGreatestCommonDivisorRecursive( 2, 13 ) : REM gives 1

 REM e.g. PRINT FNGreatestCommonDivisorRecursive( 1231232, 1234 ) : 
REM gives 2

 REM e.g. END

 REM e.g. :

 REM e.g. :

 REM e.g. :

IF number2I% = 0 THEN = number1I%

= FNGreatestCommonDivisorRecursive( number2I%, number1I% MOD 
number2I% )

: