Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How many permutations $\pi$ of $\{1,2,...,n\}$ are there such that $|\pi (i) - i|\le 1$?

How would I go about solving this with a proof and teaching it to a non-math major student?

share|cite|improve this question
for a fixed $i$, or did you mean to sum over $i$ from 1 to $n$? – Sasha Feb 20 '13 at 22:21

Let $f(n)$ denote tha number of such permutations. Let $\pi$ be such a permutation. Either $\pi(n)=n$ and the restriction to $\{1,\ldots,n-1\}$ is one of $f(n-1)$ smaller permutations of this kind. Or $\pi(n)=n-1$, necessarily $\pi(n-1)=n$ and the restriction to $\{1,\ldots,n-2\}$ is one of $f(n-2)$ smaller such permutations. We obtain the recursion $$f(n) = f(n-1)+f(n-2).$$ We check $f(1)=1$, $f(2)=2$ and therefore conclude that $f(n)$ is the $n$th Fibonacci number.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.