29 lines
693 B
Text
29 lines
693 B
Text
x = 17
|
|
y = 34
|
|
msg$ = str$(x) + " * " + str$(y) + " = "
|
|
Print str$(x) + " " + str$(y)
|
|
'In this routine we will not worry about discarding the right hand value whos left hand partner is even;
|
|
'we will just not add it to our product.
|
|
Do Until x < 2
|
|
If Not(isEven(x)) Then
|
|
product = (product + y)
|
|
End If
|
|
x = halveInt(x)
|
|
y = doubleInt(y)
|
|
Print str$(x) + " " + str$(y)
|
|
Loop
|
|
product = (product + y)
|
|
If (x < 0) Then product = (product * -1)
|
|
Print msg$ + str$(product)
|
|
|
|
Function isEven(num)
|
|
isEven = Abs(Not(num Mod 2))
|
|
End Function
|
|
|
|
Function halveInt(num)
|
|
halveInt = Int(num/ 2)
|
|
End Function
|
|
|
|
Function doubleInt(num)
|
|
doubleInt = Int(num * 2)
|
|
End Function
|