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.

A301272 Number of derangements of S_n with exactly one peak.

This page as a plain text file.
%I A301272 #53 Sep 24 2023 10:30:40
%S A301272 0,0,0,1,6,33,152,663,2778,11413,46332,186867,750878,3011025,12060480,
%T A301272 48277423,193186146,772908429,3091983236,12368675691,49476275622,
%U A301272 197908422985,791640682440,3166577409831,12666340397546,50665425902853,202661837829132,810647630936803
%N A301272 Number of derangements of S_n with exactly one peak.
%H A301272 Alois P. Heinz, <a href="/A301272/b301272.txt">Table of n, a(n) for n = 0..1663</a>
%H A301272 R. J. Cano, <a href="/A301272/a301272.txt">Sequencer program in PARI.</a>
%H A301272 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (6,-5,-16,12,16).
%F A301272 G.f.: x^3*(2*x^2+1)/((1-4*x)*(x+1)^2*(2*x-1)^2). - _Alois P. Heinz_, Apr 29 2018
%e A301272 a(3) = 1: 231.
%e A301272 a(4) = 6: 2143, 2341, 2413, 3142, 3412, 3421.
%p A301272 a:= n-> floor((<<0|1|0|0|0>, <0|0|1|0|0>, <0|0|0|1|0>, <0|0|0|0|1>,
%p A301272         <16|12|-16|-5|6>>^n. <<1/8, 0, 0, 1, 6>>)[1, 1]):
%p A301272 seq(a(n), n=0..30);  # _Alois P. Heinz_, Apr 29 2018
%t A301272 Join[{0}, LinearRecurrence[{6, -5, -16, 12, 16}, {0, 0, 1, 6, 33}, 30]] (* _Jean-François Alcover_, May 31 2019 *)
%t A301272 CoefficientList[Series[x^3(2x^2+1)/((1-4x)(x+1)^2(2x-1)^2),{x,0,40}],x] (* _Harvey P. Dale_, Sep 01 2021 *)
%o A301272 (Python)
%o A301272 def count_peaks(pi):
%o A301272     count = 0
%o A301272     for i in range(i,len(pi)-1):
%o A301272         if pi[i] > pi[i+1] and pi[i] > pi[i-1]:
%o A301272             count += 1
%o A301272     return count
%o A301272 def main(args):
%o A301272     n = int(args[0])
%o A301272     set = {1,2,...,n}
%o A301272     drmts = []
%o A301272     for pi in itertools.permutations(set):
%o A301272         drmts.append(pi)
%o A301272         for i in range(n):
%o A301272             if pi[i] == i+1:
%o A301272                 drmts.remove(pi)
%o A301272                 break
%o A301272     num = 0
%o A301272     for pi in drmts:
%o A301272         if count_peaks(pi) == 1:
%o A301272             num += 1
%o A301272     print('number of 1 peak derangements: ', num)
%o A301272 (PARI) A301272(n)={my(c=0,v,t,ok);for(k=0,n!-1,v=numtoperm(n,k);ok=1;for(i=1,n,if((v[i]==i),ok=0;break));if(ok,t=0;for(i=2,n-1,if((v[i]>v[i-1])&&(v[i]>v[i+1]),t++;if(t>1,break)));if(t==1,c++)));c} \\ _R. J. Cano_, Apr 25 2018
%o A301272 (PARI) \\ See Cano link.
%Y A301272 Cf. A000166, A001045, A216963.
%Y A301272 Column k=1 of A303564.
%K A301272 nonn,easy
%O A301272 0,5
%A A301272 _Isabella Huang_, Mar 17 2018
%E A301272 a(10)-a(20) from _Alois P. Heinz_, Apr 25 2018
%E A301272 a(21)-a(27) from _Alois P. Heinz_, Apr 29 2018