I to be wondering if over there is a method to calculate n!/(n-k)! in sage without utilizing the factorial(n) method for n and also n-k and then dividing.

You are watching: N!/(n-k)!


168 ●9 ●19 ●26

Sure, what you are looking for is the fallout’s factorial.

for n in (0..7) : <1><1, 1><1, 2, 2><1, 3, 6, 6><1, 4, 12, 24, 24><1, 5, 20, 60, 120, 120><1, 6, 30, 120, 360, 720, 720><1, 7, 42, 210, 840, 2520, 5040, 5040>
+1 due to the fact that this is a far better solution, scaling just with a, yet you have the right to look in ~ the source code yourself with "??" -- it has noticeable inefficiencies of its own. patches are motivated at trac.thedesigningfairy.com.org.


Incidentally, offered our small size, a society has arisen in i beg your pardon we often tend not come downvote answer which give correct results merely since they have suboptimal performance. poll up answer you like instead. I"ve been roughly long sufficient to fend because that myself, but I can already feel the the next time I check out a inquiry from petropolis I"ll let that sit fairly than take time to answer -- and also that was merely a endangered downvote! -- and also probably beginners would certainly feel also worse.


Sorry that i hurt your feelings. But to contact a bad solution a negative solution and to downvote a poor solution have to not be discouraged as long as the is provided in a polite type and the factor is described in a comment, IMHO. "we often tend not to downvote answers which provide correct results merely due to the fact that they have suboptimal performance"Well, check out for example Richard P. Stanley"s Enumerative Combinatorics. There you deserve to read the generating combinatorial objects and also than counting lock is *no* solution of one enumeration problem. This is what I had in mind in the an initial place when I objected your answer.


The tip to the *very* suboptimal implementation together the quotient of 2 factorials did not make points better. And after every there is a function in Sage i m sorry does exactly (if implemented correctly) what the OP thedesigningfairy.comed for: "without using the factorial(n) technique for n and also n-k and then dividing.""but ns can currently feel the the next time I see a concern from petropolis I"ll let it sit fairly than take time to reply." ns will have to live with this also so that will definitely damage the development of my discovering Sage considerably.

Even without a small size, ns say a comment first explaining your suggest is best. Would you downvote a typo? Just suggest it out and also let them solve it or delete it or whatever. And, most DEFINITELY, a correct answer the does not provide optimal performance is not to be downvoted. Upvoted the best answer. Then, everyone will understand which one is best.

I to be not in search of the binomial coefficient, what the binomial(n,k) calculates is n!/(k!(n-k)!). What ns am trying to find is a the number of ways to obtain k-permutations out of n elements. Sorry if ns was no clear.

See more: Where To Go After Old Iron King ? Where To Go After Old Iron King

Thanks, I believed doing it this means might be yes, really slow yet after some experimentation it appears that even with large inputs it doesn"t take long to calculate.

your Answer

Please start posting anonymously - your entry will certainly be released after you log in in or develop a new account.

Permutation Representations and also the Modular team

Orbits on group actions exhilaration on sets

Assigning students in teams

detect the permutation that sorts a perform

Generating permutations the coefficients

the permutation the subscripts that a multivariate polynomial

Permutations indexing from zero

counting cycles of induced permutations

Transposing a Permutatoin

need to transition a permutation (1,2,3)(4,5)->(6,7,8)(9,10)

you re welcome note: thedesigningfairy.combot calls for javascript to occupational properly, please allow javascript in her browser, below is exactly how