Paulie Posted April 1, 2007 Share Posted April 1, 2007 For use with my statistics class, I whipped up 3 functions for Combinations and Permutations The Functions; Func _nCr($n_Population, $n_Permutation) Local $top = _Factorial($n_Population) local $SubBottom1 = _Factorial($n_Permutation) local $SubBottom2 = _Factorial($n_Population-$n_Permutation) Local $Bottom = $SubBottom1*$SubBottom2 Local $result = Round($top/$bottom,0) Return $result EndFunc Func _nPr($n_Population, $n_Permutation) local $top = _Factorial($n_Population) local $Bottom = _Factorial($n_Population-$n_Permutation) Local $result = $top/$bottom Return Round($top/$bottom,0) EndFunc Func _Factorial($n_Number) Local $result = 1 For $i = $n_Number to 1 step -1 $result = $result*$i Next Return $result EndFuncoÝ÷ Ø ÄÅ©©æ®¶s`£´÷rÖçFffW&VçB6WG2öbB7GVFVçG26â&R6÷6Vâg&öÒw&÷WöbSòæ÷FS¢÷&FW"FöW6âb33·BÖGFW"£´ç7vW# ¤×6t&÷ÂgV÷C¶ä7"vVâãÓR#ÓBgV÷C²Åöä7"RÃB £´÷rÖçv26âB7GVFVçG2g&öÒw&÷WöbR&RÆæVBWf÷"÷Föw&òæ÷FS¢÷&FW"ÖGFW'2£´ç7vW# ¤×6t&÷ÂgV÷C¶å"vVâãÓR#ÓBgV÷C²Åöå"RÃB Unfortunately, for some reason (I believe it is a restriction in autoit) I am unable to produce and accurate Factorial (equal to the "!" in math) for any number greater than 20 anyway, just more math! Link to comment Share on other sites More sharing options...
Paulie Posted April 2, 2007 Author Share Posted April 2, 2007 Does anyone have an idea how to get around the problem with factorials over 20? Link to comment Share on other sites More sharing options...
Cubehead Posted April 2, 2007 Share Posted April 2, 2007 Does anyone have an idea how to get around the problem with factorials over 20?Hi Paulie, this should fix your problem. Func _Factorial($n_Number) Local $result = 1.0 ;<== my modification For $i = $n_Number to 1 step -1 $result = $result*$i Next Return $result EndFunc Cubehead Link to comment Share on other sites More sharing options...
millisys Posted November 6, 2014 Share Posted November 6, 2014 Awesome Paulie and Cubehead, this is just the solution I was looking for. Thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 6, 2014 Moderators Share Posted November 6, 2014 At least this one is only 7 years old... czardas and MikahS 2 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now