diff options
Diffstat (limited to 'challenge-090/paulo-custodio/forth/ch-2.fs')
| -rw-r--r-- | challenge-090/paulo-custodio/forth/ch-2.fs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/challenge-090/paulo-custodio/forth/ch-2.fs b/challenge-090/paulo-custodio/forth/ch-2.fs index a5386ae532..134fd22e16 100644 --- a/challenge-090/paulo-custodio/forth/ch-2.fs +++ b/challenge-090/paulo-custodio/forth/ch-2.fs @@ -2,7 +2,7 @@ \ TASK #2 › Ethiopian Multiplication \ Submitted by: Mohammad S Anwar \ You are given two positive numbers $a and $b. -\ +\ \ Write a script to demonstrate Ethiopian Multiplication using the given numbers. \ Start the script with A and B in the stack, e.g. @@ -11,16 +11,16 @@ \ The solution is just as described in the algorithm, using locals to \ simplify the stack juggling. -: mult { a b -- a*b } \ a, b: locals - 0 ( sum ) - BEGIN - a 1 AND IF \ a is even - b + \ sum += b - THEN - a 1 <= IF EXIT THEN \ exit when a=1 or a=0 - a 2/ TO a - b 2* TO b - AGAIN +: mult { a b -- a*b } \ a, b: locals + 0 ( sum ) + BEGIN + a 1 AND IF \ a is even + b + \ sum += b + THEN + a 1 <= IF EXIT THEN \ exit when a=1 or a=0 + a 2/ TO a + b 2* TO b + AGAIN ; \ input in stack |
