Check if X can be reduced to 0 in exactly T moves by substracting D or 1 from it | Function to check the above problem condition ; Check for base cases ; Check if D - 1 is a divisor of X - T ; Driver Code
function possibleReachingSequence ( X , D , T ) { if ( X < T ) { document . write ( " " ) ; return 0 ; } if ( T * D < X ) { document . write ( " " ) ; return 0 ; } if ( ( X - T ) % ( D - 1 ) == 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } return 0 ; } let X = 10 , D = 3 , T = 6 ; possibleReachingSequence ( X , D , T ) ;