Skip to content

Instantly share code, notes, and snippets.

@gubatron
Created November 28, 2013 07:07
Show Gist options
  • Save gubatron/7688283 to your computer and use it in GitHub Desktop.
Save gubatron/7688283 to your computer and use it in GitHub Desktop.
find out if a number has a perfect square.
public static boolean isPerfectSquare(int n) {
double root = Math.sqrt(n);
return root-((double)((int)root)) == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment