# How to find the total number of exchanges? [duplicate]

This question already has an answer here:

Given n objects held by n people, how to find the total number of valid exchanges, where a valid exchange means that all persons hold different objects after the exchange?

eg for 4 objects 1 2 3 4: valid exchanges are:

2 1 4 3

2 3 4 1

2 4 1 3

3 1 4 2

3 4 1 2

3 4 2 1

4 1 2 3

4 3 1 2

4 3 2 1

Therefor the total number of valid exchanges are 9.

## marked as duplicate by JMoravitz combinatorics StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jun 28 at 12:19

• There are $!n$ such "exchanges" which are more commonly known as derangements. – JMoravitz Jun 28 at 12:18
• No, $!n$ is not the same as $n!$. Read the link I posted in my comment above for the wikipedia article or read the answers in the linked post that I closed this as a duplicate of. Reading the word aloud, $!n$ is read as "n subfactorial" which is different than $n!$ which is "n factorial." The notation $!n$ is used to notate the solution to exactly the problem you are asking to count. Methods of actually calculating the values are given again in both links I provided. – JMoravitz Jun 28 at 12:21