Anonymous user
Ethiopian multiplication: Difference between revisions
move
(move) |
|||
Line 304:
1 544
= 578
==={{header|Locomotive Basic}}===▼
<lang basic>10 x=17:y=34:tot=0▼
20 WHILE x>=1▼
30 PRINT x,▼
40 IF x MOD 2 THEN tot=tot+y:PRINT y ELSE PRINT▼
50 x=INT(x/2):y=2*y▼
60 WEND▼
70 PRINT "=", tot</lang>▼
Output:▼
<pre>▼
17 34▼
8▼
4▼
2▼
1 544▼
= 578▼
</pre>▼
=={{header|C}}==
Line 1,078 ⟶ 1,058:
// eth.mult(17,34) returns 578</lang>
▲<lang basic>10 x=17:y=34:tot=0
▲20 WHILE x>=1
▲30 PRINT x,
▲40 IF x MOD 2 THEN tot=tot+y:PRINT y ELSE PRINT
▲50 x=INT(x/2):y=2*y
▲60 WEND
▲70 PRINT "=", tot</lang>
▲Output:
▲<pre>
▲ 17 34
▲ 8
▲ 4
▲ 2
▲ 1 544
▲= 578
▲</pre>
=={{header|Logo}}==
|