You are right...my thoughts were different...my sorryIf that were the case, how would you change the code to make it so that the y=y*x part was not inside the for-i loop any more?
Stuck? That's because it is already is outside.
Stick with the way you've written your program, it's fine, short of the small change with adding brackets. brack's code is wrong because it doesn't use the same random numbers for each power. He also either has no idea that you need real numbers in the range (0, 1], or doesn't understand how your code so simply does that. It's also more complicated than yours and far less efficient.
BTW, you can shorten y = y * x to just y *= x