Let total work be LCM(45,40)=360 units

Efficiencies of A & B respectively are 8 and 9 units respectively

Thus together they can complete 8+9=17 units/day

Work completed by B =9*23 =207 units

Rest of the work, which is 360-207=153 units was done by A and B together at the rate of 17 units a day.

Total number of days they would have worked together=153/17 =9

Thus A must have left after 9 days. (D)