Ethiopian multiplication: Difference between revisions
Content added Content deleted
m (→{{header|Nascom BASIC}}: Little corection: formal parameter instead of global variable.) |
(→{{header|Minimal BASIC}}: Added) |
||
Line 1,004: | Line 1,004: | ||
TextWindow.CursorLeft = 10 |
TextWindow.CursorLeft = 10 |
||
TextWindow.WriteLine(tot) |
TextWindow.WriteLine(tot) |
||
</lang> |
|||
==={{header|Minimal BASIC}}=== |
|||
<lang gwbasic> |
|||
10 REM Ethiopian multiplication |
|||
20 DEF FND(A) = 2*A |
|||
30 DEF FNH(A) = INT(A/2) |
|||
40 DEF FNE(A) = A-INT(A/2)*2-1 |
|||
50 LET X = 17 |
|||
60 LET Y = 34 |
|||
70 LET T = 0 |
|||
80 IF X < 1 THEN 170 |
|||
90 IF FNE(X) <> 0 THEN 130 |
|||
100 LET T = T+Y |
|||
110 PRINT X; TAB(9); Y; "(kept)" |
|||
120 GOTO 140 |
|||
130 PRINT X; TAB(9); Y |
|||
140 LET X = FNH(X) |
|||
150 LET Y = FND(Y) |
|||
160 GOTO 80 |
|||
170 PRINT "------------" |
|||
180 PRINT "= "; TAB(9); T; "(sum of kept second vals)" |
|||
190 END |
|||
</lang> |
</lang> |
||