Skip to content

Instantly share code, notes, and snippets.

@cwgreene
Created April 14, 2013 04:12
Show Gist options
  • Save cwgreene/5381423 to your computer and use it in GitHub Desktop.
Save cwgreene/5381423 to your computer and use it in GitHub Desktop.
int is_palindrome(long long n) {
int digits = floor(log10(n))+1;
int i;
for(i = 0; i < digits/2; i++) {
long lowdigit = ((long long)(n/pow(10,i))) % 10;
long highdigit = ((long long)(n/pow(10, (digits - 1)-i))) % 10;
if (lowdigit != highdigit) return 0;
}
return 1;
}
@cwgreene
Copy link
Author

bleh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment