cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A131502 Half the number of permutations of 0..n with a zero n-th difference.

This page as a plain text file.
%I A131502 #16 Jun 05 2024 01:25:16
%S A131502 0,0,1,1,8,3,136,29,928,942,66496,6175,2785856,205678,11122048
%N A131502 Half the number of permutations of 0..n with a zero n-th difference.
%e A131502 a(5)=3 because 0,1,2,3,4,5 ; 0,2,4,3,1,5 ; and 0,4,2,1,3,5 ; and their reverses have zero 5th differences.
%t A131502 (* naive and memory intensive implementation generating all permutations *)
%t A131502 Table[Count[
%t A131502   Map[Differences[#, n - 1] &,
%t A131502    Take[Permutations[Range[1, n]], Max[1, n!/2]]], {0}], {n, 1, 10}] (* _Olivier Gérard_, May 30 2024 *)
%o A131502 (Python)
%o A131502 from math import comb
%o A131502 from itertools import permutations
%o A131502 def A131502(n):
%o A131502     c = [-comb(n,i) if i&1 else comb(n,i) for i in range(n+1)]
%o A131502     return sum(1 for p in permutations(range(n+1)) if p[0]<p[-1] and not sum(c[i]*p[i] for i in range(n+1))) # _Chai Wah Wu_, Jun 04 2024
%K A131502 nonn,more
%O A131502 0,5
%A A131502 _R. H. Hardin_, Aug 13 2007