Created
March 21, 2018 14:49
-
-
Save fuzzygroup/abe30723713d7f79e367d98746a06afa to your computer and use it in GitHub Desktop.
Divide a number (the dividend) by another number (the divisor) without using division; assume integers and assume positive integers
This file contains 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
def divide(dividend, divisor) | |
quotient = 0 | |
while(dividend >= divisor) do | |
dividend = dividend - divisor | |
quotient = quotient + 1 | |
end | |
quotient | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment