Reversible numbers | Java program to check if a given number is reversible or not ; Function to check reversible number ; Calculate reverse of n ; Calculate sum of number and its reverse ; Check for reverse number reach digit must be odd ; Driver function
import java . io . * ; class GFG { static void checkReversible ( int n ) { int rev = 0 , rem = 0 ; int flag = n ; while ( flag > 0 ) { rem = flag % 10 ; rev *= 10 ; rev += rem ; flag /= 10 ; } int sum = rev + n ; while ( sum > 0 && ( rem % 2 != 0 ) ) { rem = sum % 10 ; sum /= 10 ; } if ( sum == 0 ) System . out . println ( " Reversible ▁ Number " ) ; else System . out . println ( " Non - Reversible ▁ Number " ) ; } public static void main ( String [ ] args ) { int n = 36 ; checkReversible ( n ) ; } }