Skip to content

Instantly share code, notes, and snippets.

@zac-xin
Created November 23, 2012 03:26
Show Gist options
  • Save zac-xin/4133876 to your computer and use it in GitHub Desktop.
Save zac-xin/4133876 to your computer and use it in GitHub Desktop.
testPalindromeNumber
package others;
public class testPalindromeNumber {
public static void main(String args[]) {
System.out.println(test(35553));
}
public static boolean test(int n) {
int k = 1;
while (n / k > 10) {
k *= 10;
}
while (n != 0) {
int i = n % 10;
int j = n / k;
if (i != j) {
return false;
}
n = (n % k) / 10;
k = k / 100;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment