Last active
October 24, 2018 23:46
-
-
Save rahuldottech/f49e97b6204a9f3be0fef91c3f27e306 to your computer and use it in GitHub Desktop.
Pseudocode for modulus and multiplication functions with only addition and subtraction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. multiplication: | |
function input --> (x*y) | |
if ( either x or y is less than zero ){ | |
FOR loop: product = subtract x from zero y times | |
} else if ( both are greater than or both are less than zero ){ | |
FOR loop: product = add x to to zero y times | |
} | |
2. modulus: | |
function input --> (m) | |
if (m<0) { | |
m = (-1*m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment