354
pages

By: Tao Steven Zheng (郑涛)

## Code

Description Hundred Fowls Problem: An indeterminate system of linear equations in the form

where are variables and are constants.

The problem originated from the Zhang Qiujian Suanjing (5th century).

``` 1 def HFP(a,b,c,d):
2     for x in range(0,101):
3         for y in range(0,101):
4             for z in range(0,101):
5                 if a*x + b*y + c*z == d and x + y + z == d:
6                     print('cocks:', x ,'hens:', y ,'chicks:', z)
7
8 '''Experiments'''
9 HFP(5, 3, 1/3, 100)
10 HFP(3,2,1/2, 100)
11 HFP(1/3,1/2,2,30)
```

## Results

HFP(5, 3, 1/3, 100)

cocks: 0 hens: 25 chicks: 75

cocks: 4 hens: 18 chicks: 78

cocks: 8 hens: 11 chicks: 81

cocks: 12 hens: 4 chicks: 84

HFP(3,2,1/2, 100)

cocks: 2 hens: 30 chicks: 68

cocks: 5 hens: 25 chicks: 70

cocks: 8 hens: 20 chicks: 72

cocks: 11 hens: 15 chicks: 74

cocks: 14 hens: 10 chicks: 76

cocks: 17 hens: 5 chicks: 78

cocks: 20 hens: 0 chicks: 80

HFP(1/3,1/2,2,30)

cocks: 0 hens: 20 chicks: 10

cocks: 9 hens: 10 chicks: 11

cocks: 18 hens: 0 chicks: 12