My solution to Factorialize a Number challenge

My solution to Factorialize a Number challenge
0.0 0

#1

Do you guys this is an okay code? Any suggestions for improvement? :slight_smile:

function factorialize(num) {
  var result = 1;
  for (var i=num; i >= 1; i--) {
    result *= i;
  }
  return result;
}

#3

Thanks a lot! Your feedback means a lot to me. :wink:


#4

I used recursion to solve mine, just because I wanted to use it! Point noted. Great post as usual, @P1xt.


#5

@Milos2709 Nice job! Your solution looks clean and efficient.


#6

Thanks @dpberry552. I am glad these algorithm challenges arenโ€™t as difficult as I feared them to be :slight_smile:


#7

Easy to understand :slight_smile:

function factorialize(num) {
  var result = 1; // set to 1 because multiplying to 0 results in 0
  for(i=1; i<=num; i++){ // get 1,2,3,4,5
    console.log(result *= i); // multiply 1*2*3*4*5*(1) = 120
  }
}
factorialize(4);