"Title"
Given the definition of a mathematical combination:
where n is the total number of selections and r is the number you are choosing from the pool.
The formula for evaluation is:
r! (n-r)!
What is the answer when you evaluate the following expression:
ok I admit I struggled with this one... I guess the main thing in understanding what the question is asking... a good place for information on this is HERE. Once you have an understanding of the functions you will need, I simply googled for a combination function: HERE
(I don't see a problem using code snippets like this as long as you understand them they are simply making your job easier, and there not solving it, just helping with a generic math function). then it's just a case of knowing what to add and subtract.
Awnser:
Source:
function fact( $num ){ $res = 1; for ($i = 2; $i <= $num; $i++){ $res *= $i; } return $res; } function perms( $n, $r ){ if( $r > $n ){ return 0; } $i = 0; $res = 1; while( $i < $r ){ $res = $res * $n; $i++; $n--; } return $res; } function combos( $n, $r ){ if( $r > $n ){ return 0; } $res = perms( $n, $r ); $res = $res / fact( $r ); return $res; } function solution(){ $solution = combos(17, 10); $solution -= combos(30, 12); $solution += combos(50, 3); echo "= ".$solution.""; }