1 answer
(click or scroll down)
If 2/5 of the remaining pens were red, there were 5/5-2/5 = 3/5 that were not red.
The number of pens that were not red is 3/5*18 = <<3/5*18=10.8>>10.8 pens
The total number of pens that were not red or black are 10.8+18 = <<10.8+18=28.8>>28.8 pens
The box of pens that Joshua bought had 28.8/5 = <<28.8/5=5.76>>5.76*5 = <<5.76*5=28.8>>28.8 pens. Answer: \boxed{28}.