maths stuff

wxdqz

New Member
in maths specifically in statistics there's something called combinations and permutations, and I need a script that will calculate combinations, they work like this,

eg. lottery, 49 balls to choose from, 6 balls are chosen, therefore the number of combinations for the balls drawn is

49 choose 6 = (49!/(49-6)!)/6! = 13983816

( 49 factorial / (49-6) factorial ) / 6 factorial

well i didn't know how to do choose so i did it in terms of factorials but i didn't know how to do those either, so i had to write my own script:
eg. if n=4

a=n

while(a>1){a=a-1; n=n*a}

and after this is run n=24 which is 4!

so with three factorial to work out like this it's very cpu intensive especially when I need it to run this up to and sometimes more than 50 times in one go, I need it to calculate the binomial distribution, if you know what that is.

basically my question is, can someone tell me how to tell the comp. to workout combinations and failing that factorials please?
 
Back
Top