I have some trouble writing out a monte carlo simulation properly.

I assign variables for the process before the steps.

The first step is assigning variable j = j + 1

Second step i draw three random numbers from a U(0,1) dist. u1, u2 and u3.

Third step is a long if formula. It has to be a function of j, V(j), so as j increases it should record a new output. The result in this step is what is used in the end to create the final result.

Fourth step is another if forumla: if(j = n) j = 0 && s = s +1 && a long formula

Fifth step is another if formula if s < S then loop to step 3

How do I create this in an efficient manner? Some of the if formulas are rather long.

Thanks for your help in advance

Morten