Copyright © University of Cambridge. All rights reserved.

'Whole Numbers Only' printed from https://nrich.maths.org/

Show menu


A student bought 17 pencils for £1.44. He paid 2 pence more for each coloured pencil than for each plain pencil. How many of each kind did he buy at what price?

You could find the answer by `trial and improvement' (or trial and tribulation as Vikki Benhae called it) but there are better methods.

Felicity, Anna and Kirsty of The Mount School, York gave this very neat solution:

Since 16 x 9 = 144 we decided that the plain pencils had to cost less than 9 pence, since these are the cheapest. We started with pencils costing 8p and colours costing 10p and worked systematically through the pairs of numbers adding to 17 and got the answer 13 pencils at 8p and 4 pencils at 10p. We tried other combinations and soon came to the conclusion that there was no other solution.

Similar solutions came from Kayleigh, Jenny, Naomi and Bethany of Maidstone Girls Grammar School. Here is how Bethany explained her reasoning:


First of all I divided £1.44 by 17.
144/17 = 8 remainder 8.
There is 8 pence left, which means there are only enough pence spare for 4 coloured pencils to be 2 pence more. Therefore my conclusion is:
13 plain pencils at 8 pence
4 coloured pencils at 10 pence.

Only read on if you are happy with algebra! Charlotte of Maidstone Girls Grammar came closest to this method of solution.

Suppose he bought n coloured pencils and (17- n ) plain pencils, the cost of a plain pencil was c pence, and the cost of a coloured pencil was ( c + 2) pence, then

(17 - n ) c + n ( c +2) = 144,

17 c + 2 n = 144.

This is a special case of a more general idea and there are infinitely many integer solutions to this equation. Just suppose the problem had been to find out all we could about ALL these solutions.

It is not difficult to find one pair of solutions. If we are looking for positive solutions then we know c is less than 9 (because 17 x 9 > 144). Also c must be even because the other terms in the equation are even.

If c = 8 then 136 + 2 n = 144 so n = 4.

Notice that if you know a single pair of values giving a solution then, for other solutions, larger values of c will correspond to smaller values of n and vice versa. If you increase c by 2 it makes the left hand side go up by 34 but if you also decrease n by 17 then it brings the left hand side down by 34 again.
If c = 10 then n = 4 - 17 = -13.
If c = 12 then n = -30 etc.
Similarly if c decreases then n increases:
If c = 6 then n = 4 + 17 = 21.
If c = 4 then n = 38 etc.

This method tells us that 8 plus any multiple of 2 and 4 minus the same multiple of 17 are pairs of solutions. The solution pairs are given by the formula
8+2 t and 4-17 t for any integer t .

This problem takes us into a corner of the number theory world where a lot of interesting work has been done and fascinating discoveries have been made. Equations which have whole number solutions are called Diophantine equations after a Greek mathematician of the third century AD. Click here and try to solve the puzzle on his tomb which tells a little bit about the life of Diophantus of Alexandria.


You can find more short problems, arranged by curriculum topic, in our short problems collection.