Ethiopian multiplication: Difference between revisions

no edit summary
No edit summary
Line 1,074:
 
// eth.mult(17,34) returns 578</lang>
 
=={{header|Liberty BASIC}}==
<lang lb>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)
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 = (num * 2)
End Function</lang>
 
=={{header|Locomotive Basic}}==