Ethiopian multiplication: Difference between revisions

Content added Content deleted
No edit summary
(→‎{{header|AutoIt}}: added tutor)
Line 160:
EndFunc
Func Ethiopian($a, $b, $fTutor = True)
If $fTutor Then _
ConsoleWrite(StringFormat("Ethiopian multiplication of %d by %d...\n", $a, $b))
Local $r = 0
whileWhile ($a >= 1)
If Not IsEven($a) Then
If $fTutor Then ConsoleWrite(StringFormat("%d\t%d\tStrike\n", $a, $b))
Else
If $fTutor Then ConsoleWrite(StringFormat("%d\t%d\tKeep\n", $a, $b))
$r += $b
EndIf
Line 169 ⟶ 174:
$b = Double($b)
WEnd
If $fTutor Then ConsoleWrite(StringFormat("Answer = %d", $r) &@LF)
Return $r
EndFunc
 
;tutor set to true writes to console
MsgBox(0, 'Ethiopian Example', Ethiopian(17, 34) )
Ethiopian(17, 34, True)
</lang>