Check if a given number is one less than twice its reverse | 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
def rev ( num ) : NEW_LINE INDENT rev_num = 0 NEW_LINE while ( num > 0 ) : NEW_LINE INDENT rev_num = ( rev_num * 10 + num % 10 ) NEW_LINE num = num // 10 NEW_LINE DEDENT return rev_num NEW_LINE DEDENT def check ( n ) : NEW_LINE INDENT return ( 2 * rev ( n ) == n + 1 ) NEW_LINE DEDENT n = 73 NEW_LINE if ( check ( n ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT