Skip to content

Instantly share code, notes, and snippets.

@Hugoyhu
Created August 2, 2020 14:13
Show Gist options
  • Save Hugoyhu/dcb5acb0280e1597215020b4fed07bab to your computer and use it in GitHub Desktop.
Save Hugoyhu/dcb5acb0280e1597215020b4fed07bab to your computer and use it in GitHub Desktop.
public class palindromecheck {
public static void main(String[] args) {
int num = 141, reversedInteger = 0, remainder, originalInteger;
originalInteger = num;
while( num != 0 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder;
num /= 10;
}
if (originalInteger == reversedInteger)
System.out.println(originalInteger + " is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment