Skip to content

Instantly share code, notes, and snippets.

@lnsp
Last active August 29, 2015 14:09
Show Gist options
  • Save lnsp/ae4dbc928959efa2c607 to your computer and use it in GitHub Desktop.
Save lnsp/ae4dbc928959efa2c607 to your computer and use it in GitHub Desktop.
Tests if a number is a palindrom
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