Hey, all

Anybody here familiar with BASAL language?

It's the first step in our class to learn C++. Now I'm STRUGGLING to write a program to calculate the least common multiple for two numbers in BASAL language. And the program should only consider the first twenty multiples of each number. Once the counters both exceed 20, it will show "no answer".

I know basically, a outer while loop and an inner one are needed, but I just can't make them right!

Here's what I have now. The LCM I got for 3 and 7 is 42!

Please help!

GET number1

GET number2

ASSIGN counter1 = (1)

ASSIGN counter2 = (1)

ASSIGN m1 = (number1)

ASSIGN m2 = (number2)

WHILE m1 != (m2)

BEGIN

ASSIGN m1 = (m1 * counter1)

IF counter1 < (20)

BEGIN

WHILE m2 != (m1)

BEGIN

ASSIGN m2 = (m2 * counter2)

ASSIGN counter2 = (counter2 + 1)

IF counter2 >= (20)

BEGIN

ASSIGN m2 = (m1)

ASSIGN answer = (-(1))

END

IF counter2 < (20)

BEGIN

ASSIGN answer = (m1)

END

END

IF answer != (-(1))

BEGIN

SHOW "FOUND"

SHOW answer

END

IF answer == (-(1))

BEGIN

ASSIGN m1 = (number1)

ASSIGN m2 = (number2)

ASSIGN counter1 = (counter1 + 1)

ASSIGN counter2 = (1)

END

END

IF counter1 >= (20)

BEGIN

ASSIGN m1 = (m2)

ASSIGN answer = (-(1))

SHOW "no answer"

END

END

agrees : In the HTML source for this page the text is only partially and inconsistently indented.