Last active
August 29, 2015 14:09
-
-
Save lnsp/ae4dbc928959efa2c607 to your computer and use it in GitHub Desktop.
Tests if a number is a palindrom
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 isPalindrom(const int n) { | |
int temp = n, reversed = 0; | |
while (temp != 0) { | |
int rem = temp % 10; | |
reversed = reversed * 10 + rem; | |
temp /= 10; | |
} | |
return reversed == n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment