30 lines
1.3 KiB
Text
30 lines
1.3 KiB
Text
// library: math: get: least: common: multiple <description></description> <version control></version control> <version>1.0.0.0.2</version> <version control></version control> (filenamemacro=getmacmu.s) [<Program>] [<Research>] [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 <description>greatest common divisor whole numbers. Euclid's algorithm. Recursive version</description> <version control></version control> <version>1.0.0.0.3</version> <version control></version control> (filenamemacro=getmacdi.s) [<Program>] [<Research>] [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
|