Question: I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number.

```
function factorialize(n) {
  for(var i = 0; i < n; i++) {
     n *= i;
  }
  return n;
}

factorialize(5);

```

so result should be `120`

I keep getting `0`

Answer: 
You should start from 1 to n.

```
function factorialize(n) {
  var ret = 1;
  for(var i = 1; i <= n; i++) {
     ret *= i;
  }
  return ret;
}

```

In the original code, `i` started from `0`. The result will always be `0` as `0 * (any number)` will result in `0`.
Please try this : 

```
function factorialize(n) {
  var p=1;
  for(var i = 1; i <=n; i++) {
     p*=i;
  }
  return p;
}

```