Largest Even and Odd N | Function to print the largest N - digit even and odd numbers of base B ; Initialise the Number ; If Base B is even , then B ^ n will give largest Even number of N + 1 digit ; To get even number of N digit subtract 2 from B ^ n ; To get odd number of N digit subtract 1 from B ^ n ; If Base B is odd , then B ^ n will give largest Odd number of N + 1 digit ; To get even number of N digit subtract 1 from B ^ n ; To get odd number of N digit subtract 2 from B ^ n ; Driver 's Code ; Function to find the numbers
def findNumbers ( n , b ) : NEW_LINE INDENT even = 0 ; NEW_LINE odd = 0 ; NEW_LINE if ( b % 2 == 0 ) : NEW_LINE INDENT even = pow ( b , n ) - 2 ; NEW_LINE odd = pow ( b , n ) - 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT even = pow ( b , n ) - 1 ; NEW_LINE odd = pow ( b , n ) - 2 ; NEW_LINE DEDENT print ( " Even ▁ Number ▁ = ▁ " , int ( even ) ) ; NEW_LINE print ( " Odd ▁ Number ▁ = ▁ " , int ( odd ) ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 2 ; NEW_LINE B = 5 ; NEW_LINE findNumbers ( N , B ) ; NEW_LINE DEDENT