Let $\mathfrak{S}\_n$ be the permutation group on $\{1,\dots,n\}$. Given $\pi=\pi\_1\pi\_2\dots\pi\_n\in\mathfrak{S}\_n$, its [major index](https://en.wikipedia.org/wiki/Major_index) statistic is denoted **maj**$(\pi)$. Define the polynomials
$$Q\_{n,k}(x):=\sum\_{\pi\in\mathfrak{S}\_n}x^{\text{maj}(\pi)+\pi\_n+\pi\_{n-1}+\cdots+\pi\_{n-k}}.$$


**EDIT.** 


**maj** can be replaced by the [inversion number](https://en.wikipedia.org/wiki/Permutation#Inversions) **inv** without affecting $Q$. This is true due to the work of [Foata and Schutzenberger](http://igm.univ-mlv.fr/~berstel/Mps/Travaux/A/1978-3MajorIndexMathNachr.pdf) on the equi-distribution of the two statistics (as multisets). However, Fedor's question made me reflect again. Is it still true that 
$\{\text{maj$(\pi)+\pi\_n+\dots+\pi\_{n-k}$}: \pi\in\mathfrak{S}\_n\}$ and
$\{\text{inv$(\pi)+\pi\_n+\dots+\pi\_{n-k}$}: \pi\in\mathfrak{S}\_n\}$ are equi-distributed? If yes, then Fedor's answer is complete.



> 
> **CLAIM.** $\,\,$ Experiment supports that, for each $n$ and $k$, we have
>  $$Q\_{n,k}(x)
> =\binom{n}{k+1} x^{(k+1)n-\binom{k+1}2}\prod\_{i=0}^k\left(1+x+\cdots+x^i\right)\prod\_{j=0}^{n-k-2}\left(1+x+\cdots+x^j\right).$$
>  Any proof?
> 
> 
> 


The above exploration was motivated by [this paper](https://arxiv.org/pdf/1504.01089.pdf).



factorization of polynomials wrt the major index stat
For inv instead of maj this is rather clear. I claim that when we fix a $(k+1)$-element subset $K$ of $\{1,2,\ldots,n\}$, the polynomial
$$\sum\_{\pi}x^{\operatorname{inv}(\pi)+\pi\_n+\pi\_{n-1}+\cdots+\pi\_{n-k}} ,$$
where the sum is running over the $\pi\in\mathfrak{S}\_n$ with $\{\pi\_{n-k},\dots,\pi\_n\} = K$,
equals
$$x^{(k+1)n-\binom{k+1}2}\prod\_{i=0}^k\left(1+x+\cdots+x^i\right)\prod\_{j=0}^{n-k-2}\left(1+x+\cdots+x^j\right).$$


Indeed, let us count the number of inversions $(\pi\_m<\pi\_j)$ for which $j<n-k\leqslant m$. For fixed $m$ the number of such inversions equals $n-\pi\_m-|i\geqslant n-k:\pi\_i>\pi\_m|$. When we sum up by all $m=n-k,\dots,n$, we get $n(k+1)-\sum\_{m\geqslant n-k} \pi\_m-\binom{k+1}2$. So, $\operatorname{inv}(\pi)+\sum\_{m\geqslant n-k} \pi\_m$ equals $n(k+1)-\binom{k+1}2$ plus the number of inversions inbetween first $n-k-1$ elements plus the number of inversions inbetween last $k+1$ elements. These are independent and have known generating polynomials $\prod\_{i=1}^s(1+x+\dots+x^{i-1})$, for $s=n-k-1$ or $s=k+1$ respectively. Thus the result.


I doubt that for maj it is true, please recheck. It should not be divisible by such a high power of $x$, since it may appear that maj is small, say, maj$=n-k-1$, and $\{\pi\_{n-k},\dots,\pi\_n\}=\{1,2,\dots,k+1\}$.


