# Sorting Algorithm : output

I faced this problem on a website and I quite can't understand the output, please help me understand it :-

Bogosort, is a dumb algorithm which shuffles the sequence randomly until it is sorted. But here we have tweaked it a little, so that if after the last shuffle several first elements end up in the right places we will fix them and don't shuffle those elements furthermore. We will do the same for the last elements if they are in the right places. For example, if the initial sequence is (3, 5, 1, 6, 4, 2) and after one shuffle we get (1, 2, 5, 4, 3, 6) we will keep 1, 2 and 6 and proceed with sorting (5, 4, 3) using the same algorithm. Calculate the expected amount of shuffles for the improved algorithm to sort the sequence of the first n natural numbers given that no elements are in the right places initially.

Input:

``````2
6
10
``````

Output:

``````2
1826/189
877318/35343
``````

For each test case output the expected amount of shuffles needed for the improved algorithm to sort the sequence of first n natural numbers in the form of irreducible fractions. I just can't understand the output.

Given an input vector of size N with no numbers in their place (they don't give you the vector because it can be shown that E[X] is the same for all vectors of N numbers with this property), which can be "Bogosorted" in k different ways, each way with `Si` shuffles and with the probability of appearance `Pi`, then `E[X] = sum(Pi * Si)/sum(Pi)` where the sum is taken over all possible ways the vector can be sorted this way (obviously, `sum(Pi) = 1` so it's actually `E[X] = sum(Pi * Si)`).