Created
August 2, 2020 14:13
-
-
Save Hugoyhu/dcb5acb0280e1597215020b4fed07bab to your computer and use it in GitHub Desktop.
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
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