Question: 5 persons (called as A, B, C, D, and E) go out fishing, and collect all the fishes in one basket. In the second day,

5 persons (called as A, B, C, D, and E) go out fishing, and collect all the fishes in one basket. In the second day, the person A first wakes up. He discards one fish, and the rest fishes are exactly divided into 5 groups. Then, A takes away one group of fishes, and leaves the rest 4 groups. Then, person B wakes up, and he takes the left 4 groups of fishes as all the fishes remain. Similarly, he discards one fish, and the rest finishes can still be exactly divided into 5 groups. Then, C, D and E all repeat the same process: (1) discard one fish from the current number of fishes he saw, (2) divide the rest fishes (after discarding one fish) exactly into 5 groups, and take away one group. Everytime after discarding one fish, the rest fishes can exactly be divided into 5 groups.

Write a C program to solve the above question by using recursion.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!