Remark
The total number of items bought is represented by 2 + 3 = 5. So for pencils to pencils + pens his ratio of pencils to total is 3/5
Equation
3/5 = 21 / x Cross multiply
3x = 5 * 21
3x = 105
x = 105/3
x = 35
Conclusion
The total number of pens and pencils that he bought was 35 <<< Answer.
Note
He bought 35 - 21 = 14 pens. That should be 2/5 of the total.
Check
2/5 * 35 = 70/5 = 14 So it checks.