Minimum number of operations required to reduce N to 0 | Function to find the minimum steps required to reduce n ; Base case ; Return answer based on parity of n ; Driver Code
def downToZero ( n ) : NEW_LINE INDENT if ( n <= 3 ) : NEW_LINE INDENT return n ; NEW_LINE DEDENT if ( n % 2 == 0 ) : NEW_LINE INDENT return 3 ; NEW_LINE DEDENT else : NEW_LINE INDENT return 4 ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 ; NEW_LINE print ( downToZero ( n ) ) ; NEW_LINE DEDENT