Minimum number of operations required to reduce N to 0 | Java Program to implement the above approach ; Function to find the minimum steps required to reduce n ; Base case ; Return answer based on parity of n ; Driver Code
class GFG { static int downToZero ( int n ) { if ( n <= 3 ) return n ; return n % 2 == 0 ? 3 : 4 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( downToZero ( n ) ) ; } }