Jump to content

Combinations and Permutaions


Paulie
 Share

Recommended Posts

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 :whistle:

anyway, just more math!

Link to comment
Share on other sites

  • 7 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...