Skip to content

Instantly share code, notes, and snippets.

@rahuldottech
Last active October 24, 2018 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahuldottech/f49e97b6204a9f3be0fef91c3f27e306 to your computer and use it in GitHub Desktop.
Save rahuldottech/f49e97b6204a9f3be0fef91c3f27e306 to your computer and use it in GitHub Desktop.
Pseudocode for modulus and multiplication functions with only addition and subtraction
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