Combinations and permutations: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Wren-trait -> Wren-iterate) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 259: | Line 259: | ||
(1000 C 998) = 499500.0, (1000 C 969) = 76023224077705100000000000000000000000000000000000000000000.0 |
(1000 C 998) = 499500.0, (1000 C 969) = 76023224077705100000000000000000000000000000000000000000000.0 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="arturo">printPermutations: function [s,b][ |
|||
print [ |
|||
"P(" ++ (to :string s) ++ ", " ++ (to :string b) ++ ") = " |
|||
permutate.count.by:b @1..s |
|||
] |
|||
] |
|||
printCombinations: function [s,b][ |
|||
print [ |
|||
"C(" ++ (to :string s) ++ ", " ++ (to :string b) ++ ") = " |
|||
combine.count.by:b @1..s |
|||
] |
|||
] |
|||
printPermutations 4 2 |
|||
printPermutations 5 3 |
|||
printPermutations 6 4 |
|||
printPermutations 7 5 |
|||
printPermutations 8 6 |
|||
printPermutations 9 7 |
|||
printPermutations 10 8 |
|||
printPermutations 11 9 |
|||
printPermutations 12 10 |
|||
printCombinations 10 8 |
|||
printCombinations 20 18 |
|||
printCombinations 30 28 |
|||
printCombinations 40 38 |
|||
printCombinations 50 48 |
|||
printCombinations 60 58 |
|||
printPermutations 340 230 |
|||
printPermutations 12503 150 |
|||
printCombinations 180 40 |
|||
printCombinations 970 730 |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>P(4, 2) = 12 |
|||
P(5, 3) = 60 |
|||
P(6, 4) = 360 |
|||
P(7, 5) = 2520 |
|||
P(8, 6) = 20160 |
|||
P(9, 7) = 181440 |
|||
P(10, 8) = 1814400 |
|||
P(11, 9) = 19958400 |
|||
P(12, 10) = 239500800 |
|||
C(10, 8) = 45 |
|||
C(20, 18) = 190 |
|||
C(30, 28) = 435 |
|||
C(40, 38) = 780 |
|||
C(50, 48) = 1225 |
|||
C(60, 58) = 1770 |
|||
P(340, 230) = 321163468667018390278490855166116943643915115883733627394541858241858716874364895663708654024956544433526906929220370657178037367849691887585605027786348781323683175128970012088045935740649918420588744620257725216845699632806302776510600871474726786041782200035955935929612857643030896557053167285732409630111804341546261862735713347179073784452257244336775041366281305006608295780372754879670614948719662927123558774623452956076264437724405141046975318837351290035912604435611648000000000000000000000000000000000000000000000000000000000 |
|||
P(12503, 150) = 145349029342353586631193854127379263889050707122840603258866143765734805000836318095430535878283222399986691383724192776832431401841845807936456562635873483263903741650446537273646795588914347285406358840689987529465482210964310466322364415189531610901593861947474126246323721536314280740814336769614384426370056684232165925069433834623283158338231715677812329656785966269970444585319639178491261742879187758508103438009278190651455732354378754778290406101258502700133885808094777181331499601845451634234055547273229226095279158651885556410705696845808314349918299242931159040000000000000000000000000000000000000000 |
|||
C(180, 40) = 18290112128130495302949953479795255876590 |
|||
C(970, 730) = 1460703798049835817371501066063364773159305309662093793682805325059313312798468600051903640905890411826065678898559485932184945661085268182815842989416642105002033447941384758262043195945021701492825484266010877073654424416642736902160</pre> |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |