Jump to content

Ethiopian multiplication: Difference between revisions

m
(Added Wren)
Line 4,576:
end = n + n
 
rem - return true (-1) if n is even, otherwise false
function even(n = integer) = integer
var one = integer
Line 4,594:
else
begin
if show then print i;" ";j;"+"
p = p + j
end
Line 4,600:
j = twice(j)
end
if show then print " =";
begin
print "----------"
print " =";
end
end = p
 
rem - exercise the function
print "Multiplying 17 times 34"
 
print ethiopian(17,34,true)
 
end</lang>
{{out}}
<pre>Multiplying 17 times 34
17 34+
8 --- 68
4 --- 136
2 --- 272
1 544+
----------
= 578</pre>
 
=={{header|Scala}}==
211

edits

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