Jump to content

Ethiopian multiplication: Difference between revisions

Add Draco
m (→‎{{header|Nascom BASIC}}: Header level lowered)
(Add Draco)
Line 2,021:
=={{header|Delphi}}==
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}}==
2,114

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.