Skip to content

Instantly share code, notes, and snippets.

@fuzzygroup
Created March 21, 2018 14:49
Show Gist options
  • Save fuzzygroup/abe30723713d7f79e367d98746a06afa to your computer and use it in GitHub Desktop.
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
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