How would I make a factorial calculator function? I need that to make a permutations and combinations calculator. I am pretty sure you would need a loop of some sort, but I'm not sure how to do it. Thanks for the help!

factorials: n × (n - 1) × (n - 2) ... 2 × 1

you can try using for loop variable to start at n and go to 1and get something to hold the product of the multiplication inside the loop

n

1

Wdym? @mwilki7

@RohilPatelthis is how you can implement the factorial function on your calculator

How do get the number of numbers before hitting 1? @mwilki7

@RohilPatel

let product = 1; for (let i = 0; i < n; i++) { product *= i; }

Is n the number ur "factorialing" by? @mwilki7

@RohilPatelyes, if i want to find the factorial of 5, n would be 5

Hmm, it's not working. @mwilki7

@RohilPatelwhat are the results you are getting

Try it ur self. @mwilki7

@RohilPatel Make the iterator start from 1 and not 0. Multiplication by 0 just makes the product, well, 0.

@SixBeepsshoot how did i miss that

@mwilki7 Don't worry, I spent all morning today wondering why my webpage wasn't running. Turns out I spelled "replace" as "replase" :/

## How would I make a factorial calculator function?

How would I make a factorial calculator function? I need that to make a permutations and combinations calculator. I am pretty sure you would need a loop of some sort, but I'm not sure how to do it. Thanks for the help!

factorials: n × (n - 1) × (n - 2) ... 2 × 1

you can try using for loop variable to start at

`n`

and go to`1`

and get something to hold the product of the multiplication inside the loop

Wdym? @mwilki7

@RohilPatel

this is how you can implement the factorial function on your calculator

How do get the number of numbers before hitting 1? @mwilki7

@RohilPatel

@RohilPatel

Is n the number ur "factorialing" by? @mwilki7

@RohilPatel

yes, if i want to find the factorial of 5, n would be 5

Hmm, it's not working. @mwilki7

@RohilPatel

what are the results you are getting

Try it ur self. @mwilki7

@RohilPatel Make the iterator start from 1 and not 0. Multiplication by 0 just makes the product, well, 0.

@SixBeeps

shoot how did i miss that

@mwilki7 Don't worry, I spent all morning today wondering why my webpage wasn't running. Turns out I spelled "replace" as "replase" :/