Created
September 15, 2018 01:14
-
-
Save completejavascript/8d0e3acf04782a77cfa03c58ae4e8f3b to your computer and use it in GitHub Desktop.
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
bool IsSquareNumber(int a) | |
{ | |
int left = 1, right = a, m; | |
while(left < right) | |
{ | |
m = (left + right) / 2; | |
if(m*m > a) right = m - 1; | |
else if(m*m < a) left = m + 1; | |
else return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment