// library: math: get: least: common: multiple 1.0.0.0.2 (filenamemacro=getmacmu.s) [] [] [kn, ri, su, 20-01-2013 14:36:11] INTEGER PROC FNMathGetLeastCommonMultipleI( INTEGER x1I, INTEGER x2I ) // RETURN( x1I * x2I / FNMathGetGreatestCommonDivisorI( x1I, x2I ) ) // END // library: math: get: greatest: common: divisor greatest common divisor whole numbers. Euclid's algorithm. Recursive version 1.0.0.0.3 (filenamemacro=getmacdi.s) [] [] [kn, ri, su, 20-01-2013 14:22:41] INTEGER PROC FNMathGetGreatestCommonDivisorI( INTEGER x1I, INTEGER x2I ) // IF ( x2I == 0 ) // RETURN( x1I ) // ENDIF // RETURN( FNMathGetGreatestCommonDivisorI( x2I, x1I MOD x2I ) ) // END PROC Main() // STRING s1[255] = "10" STRING s2[255] = "20" REPEAT IF ( NOT ( Ask( "math: get: least: common: multiple: x1I = ", s1, _EDIT_HISTORY_ ) ) AND ( Length( s1 ) > 0 ) ) RETURN() ENDIF IF ( NOT ( Ask( "math: get: least: common: multiple: x2I = ", s2, _EDIT_HISTORY_ ) ) AND ( Length( s2 ) > 0 ) ) RETURN() ENDIF Warn( FNMathGetLeastCommonMultipleI( Val( s1 ), Val( s2 ) ) ) // gives e.g. 10 UNTIL FALSE END