Ethiopian multiplication: Difference between revisions
Content added Content deleted
(→{{header|BASIC}}: Locomotive BASIC example) |
|||
Line 304: | Line 304: | ||
1 544 |
1 544 |
||
= 578 |
= 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}}== |
=={{header|C}}== |