'=========================================================================== ' Subject: LEAST COMMON MULTIPLE (LCM) Date: 11-24-98 (22:29) ' Author: Jeff Connelly Code: QB, QBasic, PDS ' Origin: shellreef@email.msn.com Packet: ALGOR.ABC '=========================================================================== ' Created:09-22-98 ' By Jeff Connelly ' Calcuates the least common multible (LCM) of two numbers REM $DYNAMIC ' For dynamic array resizing ' These arrays initally contain only one element, will be REDIMed later DIM aa&(0) DIM ab&(0) INPUT "Multible array size: ", size REDIM aa&(size) REDIM ab&(size) INPUT "First number: ", a INPUT "Second number: ", b ' Build the array of factors PRINT "Calculating multibles of "; a; " and "; b; "..." free = UBOUND(aa&) n = 0 FOR i = 0 TO UBOUND(aa&) n = n + a aa&(i) = n NEXT n = 0 FOR i = 0 TO UBOUND(ab&) n = n + b ab&(i) = n NEXT PRINT "Calculating least common multible..." FOR i = 0 TO UBOUND(aa&) FOR j = 0 TO UBOUND(ab&) IF (aa&(i) = ab&(j)) THEN PRINT "LCM found: "; aa&(i): END NEXT NEXT PRINT "Sorry, the LCM was not found. Please increase the multible array" PRINT "size. If you just want to know *any* common multible, just multiply" PRINT "the two values together (i.e, "; a; " * "; b; " = "; a * b; ")"