# TADM2E 3.28

From Algorithm Wiki

Revision as of 18:13, 11 September 2014 by Algowikiadmin (Talk | contribs)

We need two pass over X:

1. Calculate cumulative production P and Q:<br> <math>P_0 = 1, P_k=X_k P_{k-1}=\prod_{i=1}^kx_i</math><br> <math>Q_n = 1, Q_k=X_k Q_{k+1}=\prod_{i=k}^nx_i</math>

2. Calculate M:<br> <math>M_k=P_{k-1}Q_{k+1}, k\in[1,n]</math>