Or if you have not heard of recursion, see if this makes sense to you. It's not really practical in PowerPro due to low limits on nested function calls, but it's fun to know the concept:
win.debug(fact(5)) function fact(n) if (n<=1) quit(1) quit(n*fact(n-1)) // cannot use ifelse function because PPro always evaluation all arguments --- In [email protected], "DavidC" <hot...@...> wrote: > > Hi Wai, > Use this instead: > > Local v r > r=1 > For (v=5;v>=1;v=v-1);;Will loop as long as v is greater than or equal to 1 > r = r*v > EndFor > > win.debug(r) > > > --- In [email protected], "Wai" <chunwaihome@> wrote: > > > > I write the following script to calculate 5x4x3x2x1, but the result is > > wrong.What wrong? > > > > Local v r > > r=1 > > For (v=5;v=1;v=v-1) > > r = r*v > > EndFor > > > > win.debug(r) > > >
