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.
%I A152665 #21 Apr 02 2024 12:07:20 %S A152665 0,1,2,16,60,540,3024,32256,241920,3024000,28512000,410572800, %T A152665 4670265600,76281004800,1017080064000,18598035456000,284549942476800, %U A152665 5762136335155200,99527809425408000,2211729098342400000,42575785143091200000,1030334000462807040000 %N A152665 Number of leading even entries in all permutations of {1,2,...,n}. %F A152665 a(n) = Sum_{k=0..floor(n/2)} k*A152664(n,k). %F A152665 a(2n+1) = n(2n+1)!/(n+2); %F A152665 a(2n) = n(2n)!/(n+1). %F A152665 D-finite with recurrence 2*(n+3)*a(n) +(-5*n-8)*a(n-1) +(-2*n^3-2*n^2-n-4)*a(n-2) +(n-2)*(3*n^2-3*n+2)*a(n-3) +(n-3)*(n-2)^2*a(n-4)=0. - _R. J. Mathar_, Jul 26 2022 %e A152665 The permutation 4,6,2,1,5,3 begins with three even numbers, so would contribute 3 to a(6). %e A152665 a(3)=2 because in the permutations 123, 132, 213, 231, 312, 321 we have 0+0+1+1+0+0 = 2 leading odd entries. %e A152665 a(45) = 16: Here are the permutations of 1234, 24 in all: %e A152665 1(234) total 6, no. of initial even terms = 0 %e A152665 3(124) ditto %e A152665 21(34) total 2, no. of initial even terms 1*2 = 2 %e A152665 23(14) ditto %e A152665 24(13) total 2, no. of initial even terms 2 twice = 4 %e A152665 Subtotal from 2*** is 2+2+4 = 8 %e A152665 Subtotal from 4*** is also 2+2+4 = 8 %e A152665 Total a(4) = 8+8 = 16. %p A152665 ao := proc (n) options operator, arrow; n*factorial(2*n+1)/(n+2) end proc: ae := proc (n) options operator, arrow; n*factorial(2*n)/(n+1) end proc: a := proc (n) if `mod`(n, 2) = 1 then ao((1/2)*n-1/2) else ae((1/2)*n) end if end proc; seq(a(n), n = 1 .. 20); %t A152665 a[n_] := If[OddQ[n], (n-1)*n!/(n+3), n*n!/(n+2)]; %t A152665 Table[a[n], {n, 1, 20}] (* _Jean-François Alcover_, Apr 29 2023 *) %Y A152665 Cf. A152662, A152663, A152664. %K A152665 nonn %O A152665 1,3 %A A152665 _Emeric Deutsch_, Dec 13 2008 %E A152665 Examples expanded by _N. J. A. Sloane_, Sep 09 2019