Code for simulation of moments recursion formulas