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 the base case . ; check if X - T is a divisor of D - 1 ; Driver code
def possibleReachingSequence ( X , D , T ) : NEW_LINE INDENT if X < T : NEW_LINE INDENT return " NO " NEW_LINE DEDENT if T * D < X : NEW_LINE INDENT return " NO " NEW_LINE DEDENT if ( X - T ) % ( D - 1 ) == 0 : NEW_LINE INDENT return " YES " NEW_LINE DEDENT return " NO " NEW_LINE DEDENT X = 10 NEW_LINE D = 3 NEW_LINE T = 6 NEW_LINE print ( possibleReachingSequence ( X , D , T ) ) NEW_LINE