D=Dennis, S=Sharon.
If D takes 5 days then he works at the rate of 1/5 of the job a day; and S works at 1/8.
When they work together their rates are combined: 1/5+1/8=13/40 job in one day.
Together they complete the job in 40/13=3 1/13=3.08 (approx.) days because 13/40 is completed in one day.
To grasp this better imagine the job is to stack 40 boxes. If D can stack them in 5 days he must be stacking 8 per day and S only 5 a day. Together they can stack 13 boxes a day. In two days they will stack 26, in three it will be 39. They only have to stack one box between them on the 4th day, so it won't take them all day. It will only take them 1/13 of a day (less than 2 hours).