1

I was reading this interesting question and I see that the general answer is the same of the Hertzsprung's problem (A002464).

Now if I consider the case including $0$ so the $ n $ digits are $[0, 1,..., n-1]$, what would be the answer? Of course the number can't start with $0$.

user967210
  • 1,464
  • 5
  • 15
  • I don't see those problems as identical...the menage sequence just blocks permutations with $\sigma (i)\in {i, i+1\pmod n}$. Am I misreading something? – lulu Jun 02 '23 at 16:31
  • You say you tested small numbers and found the ménage problem was the same as this problem. However, when $n=5$, there are $12$ valid permutations, namely $ (1, 3, 0, 2, 4), (1, 3, 0, 4, 2), (1, 4, 2, 0, 3), (2, 0, 3, 1, 4), (2, 0, 4, 1, 3), (2, 4, 0, 3, 1), (2, 4, 1, 3, 0), (3, 0, 2, 4, 1), (3, 1, 4, 0, 2), (3, 1, 4, 2, 0), (4, 1, 3, 0, 2), (4, 2, 0, 3, 1)$, $\tag*{}$ but the answer to the ménage problem is $13$. Is there something I am misunderstanding? – Mike Earnest Jun 02 '23 at 16:54
  • @MikeEarnest sure, as I said I just tried with small $n$ like $4$ and $5$ and the result is respectiveli $2$ and $13$ – user967210 Jun 02 '23 at 17:03
  • 1
    You say there are $13$ permutations, I listed $12$ of them. Which one am I missing? – Mike Earnest Jun 02 '23 at 17:05
  • 1
    @MikeEarnest no, you are right, I added a wrong one. I edit the post – user967210 Jun 02 '23 at 17:23

1 Answers1

1

Let $a_n$ be the number of permutations of $[0,1,\dots,n-1]$ such that adjacent list entries are never consecutive numbers, as listed in https://oeis.org/A002464.

Let $b_n$ be the number of such permutations, where we additionally require the first element to be nonzero.

You can show that, for all $n\ge 2$, $$ b_n=a_n-b_{n-1}\tag1 $$ Why? Because the permutations counted by $a_n$ fall into two classes; those whose first element is $0$, and those whose first entry is nonzero. There are $b_n$ permutations whose first entry is nonzero, by definition of $b_n$. If the first entry is zero, then the remaining entries must be a permutation of $[1,2,\dots,n-1]$ whose first entry is not equal to $1$, which is exactly the same as $b_{n-1}$.

If you iterate equation $(1)$, you get a formula for $b_n$ in terms of the numbers $a_4,a_5,\dots,a_n$: $$ b_n=a_n-a_{n-1}+a_{n-2}-a_{n-3}+\dots+(-1)^{n-4}a_4\tag2 $$ Since the OIES page for $a_n$ does not give a closed formula, and $a_n$ can be written as $b_n+b_{n-1}$, we should not expect a closed formula for $b_n$. Therefore, the formula in $(2)$ is probably the best you can do.

Mike Earnest
  • 84,902