MathBin | Diophantine Equation - Farm Animals | Member |
---|

A farmer spent $100 to buy 100 animals of three different kinds. Each cow cost $10, each pig $3, and each sheep 50 cents. Assuming he bought at least one of each, how many of each animal did the farmer buy?

Cows | Pigs | Sheep | Total | Goal | |
---|---|---|---|---|---|

Count | |||||

Cost ($) | |||||

Sum ($) | |||||

Note: Most of this analysis is from the book "Wheels, Life and other Mathematical Amusements" by Martin Gardner. I own this book and many other books by him.

There are two equations in three unknowns, where `x` is the number of cows, `y` the number of pigs, and `z` the number of sheep.

`x`+`y`+`z`= 100- 10
`x`+ 3`y`+`z`/2 = 100

Solve the first equation for `z`, and multiply the second equation by 2 to remove the fraction.

`z`= 100 -`x`-`y`- 20
`x`+ 6`y`+`z`= 200

Eliminate `z` from the second equation.

`z`= 100 -`x`-`y`- 19
`x`+ 5`y`= 100

Use **continued fractions** to find integral values of `x` and `y`.

- Put term with smallest coefficient (5) on left: 5
`y`= 100 - 19`x` - Divide both sides by 5:
`y`= (100 - 19`x`)/5 - Divide each term and put remainder (if any) over 5 to form a terminal fraction

We now have: `y` = 20 - 3`x` - 4`x`/5. For `x` and `y` to be integers, `x` must have a positive value that makes 4`x`/5 an integer, so `x` must be a multiple of 5.

The one and only solution to this problem is when `x` = 5, `y` = 1, and `z` = 94. The means the farmer bought 5 cows, 1 pig, and 94 sheep for a cost of $10 * 5 + $3 * 1 + $0.50 * 94 = $50 + $3 + $47 = $100.

Question: Is there a solution if cows cost $5, pigs are $2, and sheep are $0.50? What if cows are $4, pigs are $2, and sheep are one-third of a dollar?