Returns an array that actually represents the permutation algorithm.

It receives an array, and has to return an array of indexes, of the values that are in the index indicated by p(x), where x: 1 < x < n;

function perm(initialArray) {
    const maxLength = initialArray.length;
    let arrayTemp = [];
    
    for (let i = 1; i <= maxLength; i++)
    {
        for(let j = 0; j < maxLength; j++){
            if ( initialArray[j] === i )
            {
                for (let k = 0; k < maxLength; k++){
                    if ( initialArray[k] === j+1 ){
                        arrayTemp.push(k+1);
                    }
                }
            }
        }
    }
    
    return arrayTemp;
}

By davs