It is 160. We must take into account all the possible conditions, 5! + 40 gives you the answer... Detailed answer would go tooooo long.
However here you go:
(This is from a cayley paper, not my content) Also, teh exclamatory marks are arrows denoting direction of giving/receiving.)
We solve this problem by rst determining the possible structures of the exchange within the
book club. Then, we count the number of ways the friends can be t into the structures.
Suppose that the six friends exchange books as described.
Consider one person, who we call A.
A must give a book to a second person, who we call B (A ! B).
B cannot give a book back to A, so must give a book to a third person, who we call C
(A ! B ! C).
C cannot give a book to B since B already receives a book from A. Therefore, C can give
a book to A (A ! B ! C ! A) or C can give a book to a fourth person, who we call D
(A ! B ! C ! D).
{ In the rst case (A ! B ! C ! A), each of A, B and C already both give and receive
a book. Therefore, the fourth person, who we call D, must give a book to a fth person,
who we call E (A ! B ! C ! A; D ! E).
E cannot give a book back to D and cannot give to any of A, B or C, so must give a book
to the sixth (and nal) person, who we call F (A ! B ! C ! A; D ! E ! F).
The only person that F can give a book to is D, since everyone else already is receiving
a book. This completes this case as (A ! B ! C ! A; D ! E ! F ! D).
{ The other option from above is A ! B ! C ! D.
Here, D cannot give a book to B or C who each already receive a book. Thus, D gives a
book to A or to one of the two remaining people.
If D gives a book to A, then each of A, B, C and D both gives and receives, so the nal
two people are left to exchange books with each other, which is not possible.
Therefore, D gives a book to one of the remaining people, who we call E (giving
A ! B ! C ! D ! E).
Only two people have not received a book now: A and the sixth person, who we call F.
E must give a book to F, otherwise F does not give or receive a book at all. Thus, F
must give a book to A.
This gives the structure A ! B ! C ! D ! E ! F ! A.
Therefore, there are two possible structures for the exchanges: A ! B ! C ! A with
D ! E ! F ! D, and A ! B ! C ! D ! E ! F ! A.
(We can think of the rst structure as two cycles of three people, and the second as one cycle
of six people.)
Suppose the six friends are P, Q, R, S, T, and U. (We could call them Peter, Quinn, Rad,
Steve, Troy, and Ursula, but will use abbreviations to save space.) We must count the number
of ways that these six friends can be assigned to the positions A through F in the two structures
above. We have to be careful because assigning
A ! B ! C ! A D ! E ! F ! D
P Q R P S T U S
in the rst structure is the same as assigning
A ! B ! C ! A D ! E ! F ! D
U S T U Q P R Q
but is dierent from assigning
A ! B ! C ! A D ! E ! F ! D
P R Q P S T U S
{ Case 1: A ! B ! C ! A with D ! E ! F ! D
Because this case consists of two cycles of three people each, each person serves exactly
the same function, so we can assign P to position A.
There are then 5 possible friends for position B (all but P).
For each of these, there are 4 possible friends for position C (all put P and the friend in
position B). This completes the rst cycle.
Now, the remaining three friends must complete the second cycle.
Suppose without loss of generality that these three friends are S, T and U.
Since each of the three positions in the second cycle serves exactly the same function, we
can assign S to position D.
There are then 2 possible friends for position E (either T or U).
For each of these, there is 1 possible friend left to go in position F.
This gives 5 4 2 1 = 40 ways of assigning the friends to this structure.
{ Case 2: A ! B ! C ! D ! E ! F ! A
Because this case is a single cycle of six people, each person serves exactly the same
function, so we can assign P to position A.
There are then 5 possible friends for position B (all but P).
For each of these, there are 4 possible friends for position C (all put P and the friend in
position B).
Similarly, there are 3 possibilities for position D, 2 for position E, and 1 for position F.
This gives 5 4 3 2 1 = 120 ways of assigning the friends to this structure.
Therefore, there are 40 + 120 = 160 ways in total in which the books can be exchanged.