Advertisement
ffpaladin

palindrome

Apr 7th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1.  
  2. public class Palindrome {
  3.  
  4.     public static void main(String[] args){
  5.        
  6.         System.out.println(intPalindrome(1234321));
  7.     }
  8.    
  9.     public static boolean intPalindrome(int n){
  10.        
  11.         int temp = n;
  12.        
  13.         int reverse = 0;
  14.        
  15.         for (int i = 10; temp > 0; i *= 10){
  16.             reverse += temp%10*i/10;
  17.            
  18.             temp = temp/10;
  19.            
  20.             System.out.println(i);
  21.             System.out.println(temp);
  22.         }
  23.        
  24.         if (n == reverse){
  25.             return true;
  26.         }
  27.         else
  28.             return false;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement