From 3ebca0da7e250b7e74373d1e38ac1ae567329929 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 5 Feb 2020 10:21:40 -0800 Subject: [PATCH] Cleanup algorithm steps for clarity --- README.MD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.MD b/README.MD index af0d553..bbf0961 100644 --- a/README.MD +++ b/README.MD @@ -34,12 +34,12 @@ An alternative algorithm to implement multiplication using only: # Algorithm -1. Initialize Sum <- zero. In C nomenclature: `Sum = 0;` -2. If B is odd then add A to Sum. In C nomenclature: `if( B & 1 ) Sum += A;` -3. Multiply A by 2 -- that is, Shift A **left** by one. In C nomenclature: `A <<= 1;` -4. Divide B by 2 -- that is, Shift B **right** by one. In C nomenclature: ` B >>= 1;` -5. If B is zero then STOP. `while( b ) { ... }` -6. Goto step 2 +1. Initialize sum <- ZERO. +2. IF b is ZERO then STOP. +3. IF b is ODD then ADD a to sum. +4. MULTIPLY a by 2. That is, shift a **left** once. +5. DIVIDE b by 2. That is, shift b **right** once. +6. GOTO step 2 Paste the following program into an [online C compiler](https://www.onlinegdb.com/online_c_compiler)