Check if a given number is one less than twice its reverse | Java program of the above approach ; Iterative function to reverse digits of num ; Loop to extract all digits of the number ; Function to check if N satisfies given equation ; Driver Code
import java . util . * ; class GFG { static int rev ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static boolean check ( int n ) { return 2 * rev ( n ) == n + 1 ; } public static void main ( String [ ] args ) { int n = 73 ; if ( check ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }