Let's pick up a Number which is the LCM of both of A and B's rates, for eg. 60.
Here, let 60 be the total units of work to be done.
So, if A takes 20 days to finish 60 units, it means he accomplishes 60/20= 3 units per day.
Similarly, if B takes 30 days to finish 60 units, he accomplishes 60/30= 2 units per day
Now, the total work done by them in 1 day= 3+2= 5 units.
For the 5 days B worked by himself, he gets 5*2 units= 10 units done.
The 4 days A and B work together in the end, they get 4* 5 units= 20 units done.
Total work done= 30 units.
Leftover work= 60-30 units= 30 units. This is the work that A and B must have done together, before A left.
So, given the combined rate, A and B together must have done 30 units in 30/5= 6 days!