Jozhua bought a box of pens. 1/8 of the pens were black 1/4 were blue abd 2/5 of the remaining were red. If there were 18 red pens how many pens did she buy?

Let X be the number of pens Jozhua bought

There were 2/5 of X pens that were red leaves 18 / (2/5) = <<18/(2/5)=45>>45 pens
There were X - 45 of the pens that were not red
There were 1/4 * (X - 45) = 18 pens that were blue
So X - 45 = 18 * 4 = <<18*4=72>>72
Thus Jozhua bought X = 72 + 45 = <<72+45=117>>117 pens. Answer: \boxed{117}.