Last active
December 20, 2015 18:18
-
-
Save xjia1/6174584 to your computer and use it in GitHub Desktop.
Computing the integer square root of n
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
k = 0 | |
j = 1 | |
m = 1 | |
while m <= n | |
k = k + 1 | |
j = j + 2 | |
m = m + j | |
end | |
# the answer is in k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
j = 1 3 5 7 9 ...
m = 1 4 9 16 25 ...