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