Created
October 28, 2013 18:25
-
-
Save jonatasemidio/7201977 to your computer and use it in GitHub Desktop.
Division Algorithm in groovy
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
//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