Friday, November 2, 2012

An Classic and Interesting issue in Math

In China, there are some interesting issues in math. Now let us enjoy one of them, a very classic indeterminate equation question--in ancient China, how to use one hundred penny(penny is the unit of measurement of money in ancient China) to buy one hundred chicken.

The topic is very simple: one rooster will cost 5 penny, one hen will cost 3 penny, but three chicken only cost 1 penny. Now, you have 100 penny to buy them, the requirements are as follows:
            1. all kinds of chicken you should buy.
            2. how many roosters, hens and chicks you buy will cost 100 penny?

Analysis: we can set up a rooster is x, the hen is y Chicken is z, then we can draw the indeterminate equation:
                 x+y+z=100
                5x+3y+z/3=100
 As we have only 100 penny, we can get the result 0<5x<100, so 0<x<20, similarly, we will get result 0<y<33 and z=100-x-y.

Until now, the program comes out:

let rooster()=
     for x=1 to 19 do
         for y=1 to 32 do
             let z= 100-x-y
             if ((z%3=0)&&(5*x+3*y+z/3=100)) then
                 printfn "You should buy %d rooster, %d hen, %d chicks" x y z

It is a very easy quetion, is it?

No comments:

Post a Comment