Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 01:14
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 completejavascript/8d0e3acf04782a77cfa03c58ae4e8f3b to your computer and use it in GitHub Desktop.
Save completejavascript/8d0e3acf04782a77cfa03c58ae4e8f3b to your computer and use it in GitHub Desktop.
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