Convert A into B by incrementing or decrementing 1 , 2 , or 5 any number of times | Function to find minimum number of moves required to convert A into B ; Stores the minimum number of moves required ; Stores the absolute difference ; FInd the number of moves ; Return cnt ; Input ; Function call
function minimumSteps ( a , b ) { let cnt = 0 ; a = Math . abs ( a - b ) ; cnt = Math . floor ( a / 5 ) + Math . floor ( ( a % 5 ) / 2 ) + ( a % 5 ) % 2 ; return cnt ; } let A = 3 , B = 9 ; document . write ( minimumSteps ( A , B ) ) ;