john has exactly 31 pens , and each pen is either bule , black , or red . if he has 5 more black pens than red pens , and twice as many blue pens as black pens , how many blue pens does john has ?
x = the number of blue pens y = the number of black pens z = the number of red pens from the first sentence we have equation # 1 : x + y + z = 31 . . . he has 5 more black pens than red pens . . . equation # 2 : y = 5 + z . . . twice as many blue pens as black pens . . . equation # 3 : x = 2 y solve equation # 1 for z : z = y - 5 now , we can replace both x and z with y in equation # 1 2 y + y + ( y - 5 ) = 31 4 y - 5 = 31 4 y = 36 y = 9 there are 9 black pens . this is 5 more than the number of red pens , so z = 4 . hence the answer is . x = 18 , and just for check 18 + 9 + 4 = 31 . answer = 18 , ( b )
multiply(divide(add(31, 5), const_4), const_2)