var ans = (49*48*47*46*45*44)/(6*5*4*3*2*1)
alert(ans.toLocaleString())
This will output 13,983,816 and it's the correct number of possible combinations from a number array of 1 to 49.
How do I implement this with numbers that I can get from 2 variables?
For example if I want to calculate the number of combinations possible for 5 numbers out of 40 I need to have (40*39*38*37*36)/(5*4*3*2*1) and I need this to be replaced like: 40*39*38*37*36 with var n and (5*4*3*2*1) with var t but output the correct order of numbers.
Just to be clear, I don't want to write these operations manually in the variables, I want the number specified in the variables to generate the operations based on their value. If I specify 6 selections I need to generate 6*5*4*3*2*1, if I specify 5 selections it needs to generate 5*4*3*2*1 and so on.
Thanks for the help!
Nevermind, I managed to figure it out after some good hours: