# Burmester Desmedt confused on the last step

I try to implement in code the traditional burmester desmedt algorithm for group key agreement: But I have the following question regarding the last step:

$$K=k_{i-1}^{nx_i}K_i^{n-1}K_i+1^{n-2}\dots K_{i-2} \pmod p$$

But when it comes down to boil into code I find hard time to understand what operations are actually executed

First of all does the $$K_i^{n-1}$$ is resulted in pseudocode as mentioned bellow?

value = participant.length-1
power(participant[i].K, participant.length-1)


Where power is raising into power participant[i] represents the ith participant and participant.length-1. Also should execute the execution above until until value it turned into 0 meaning:

 value = participant.length-1
index=i
do {
power(participant[index].K, value)
index ++
value --
} while(value=0)


Also after that what other calulations are required I mean there also a $$K_{i-2}$$ how after that I will what loop do I need to execute should I just iterate through Calculated $$K$$ values for each participant and just multiply them from i to i-2 in reverse order?