text: Minimum steps to reduce N to 0 by given operations | Function to find the minimum number to steps to reduce N to 0 ; Base case ; Recursive call to count the minimum steps needed ; Return the answer ; Given number N ; Function call
code: function minDays ( n ) { if ( n < 1 ) return n ; var cnt = 1 + Math . min ( n % 2 + minDays ( parseInt ( n / 2 ) ) , n % 3 + minDays ( parseInt ( n / 3 ) ) ) ; return cnt ; } var N = 6 ; document . write ( minDays ( N ) ) ;