Skip to content

Instantly share code, notes, and snippets.

@jonatasemidio
Created October 28, 2013 18:25
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 jonatasemidio/7201977 to your computer and use it in GitHub Desktop.
Save jonatasemidio/7201977 to your computer and use it in GitHub Desktop.
Division Algorithm in groovy
//Based on https://gist.github.com/israelst/2041698
//See it working http://groovyconsole.appspot.com/script/1265001
def dv(x, y){
result = [q : 0, r : 0]
while (x >= y){
x -= y
result.q += 1
}
result.r = x
result
}
dv(4, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment