Ethiopian multiplication: Difference between revisions
Content added Content deleted
m (→{{header|Nascom BASIC}}: Header level lowered) |
Not a robot (talk | contribs) (Add Draco) |
||
Line 2,021: | Line 2,021: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
See [https://rosettacode.org/wiki/Ethiopian_multiplication#Pascal Pascal]. |
See [https://rosettacode.org/wiki/Ethiopian_multiplication#Pascal Pascal]. |
||
=={{header|Draco}}== |
|||
<lang draco>proc nonrec halve(word n) word: n >> 1 corp |
|||
proc nonrec double(word n) word: n << 1 corp |
|||
proc nonrec even(word n) bool: n & 1 = 0 corp |
|||
proc nonrec emul(word a, b) word: |
|||
word total; |
|||
total := 0; |
|||
while a > 0 do |
|||
if not even(a) then total := total + b fi; |
|||
a := halve(a); |
|||
b := double(b) |
|||
od; |
|||
total |
|||
corp |
|||
proc nonrec main() void: writeln(emul(17, 34)) corp</lang> |
|||
{{out}} |
|||
<pre>578</pre> |
|||
=={{header|E}}== |
=={{header|E}}== |