Created
April 14, 2013 04:12
-
-
Save tessprime/5381423 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bleh.