1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2012
Posts
3
Rep Power
0

#### BASAL problem

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!

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)
END
IF counter2 < (20)
BEGIN
END
END
BEGIN
SHOW "FOUND"
END
BEGIN
ASSIGN m1 = (number1)
ASSIGN m2 = (number2)
ASSIGN counter1 = (counter1 + 1)
ASSIGN counter2 = (1)
END
END
IF counter1 >= (20)
BEGIN
ASSIGN m1 = (m2)
END
END
2. Find another class! How can any rational person think that teaching a totally unrelated language is the same as teaching C++? If you are at the level where you are learning basics about programming, you shouldn't be in a C++ class to begin with!
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2012
Posts
3
Rep Power
0
Originally Posted by mitakeet
Find another class! How can any rational person think that teaching a totally unrelated language is the same as teaching C++? If you are at the level where you are learning basics about programming, you shouldn't be in a C++ class to begin with!
I know!
And I doubt on which earth is the BASAL still used in programming...
But this LCM thing is killing me right now. In the desired result, the two counters should equal 102. How fascinating!
4. Well, good luck finding someone who knows the syntax. I can state with certainty, though, that if you preserve indentation (if you didn't indent your original code, you should!) in your post using "code" tags you are much more likely to get some input, at least from a pseudocode analysis standpoint.