Search code examples
algorithmmathfactorial

What would be an efficient way of calculating ratio of two factorials with arbitrary precision?


In a research paper, I read the following statement

The computations of S (...) and C (...) involve computing ratios of factorials such as (2n)!/(2k)!, where 0 ≤k ≤ n. This can be done in time O(n^2(logn)^2) by a straightforward algorithm.

They have not mentioned which straightforward algorithm they are talking about. If they are talking about direct multiplication of integers, then according to this link, the total time for n! calculation alone would be O(n^2 log n) which leaves us with around O(log n) time for division, which I think is not possible.

One approach which I can think of is:- 1.) Choosing a fast factorial algorithm from here. 2.) Dividing using Schönhage–Strassen algorithm combined with Newton’s reciprocal method.

It's just an initial idea though.

Is there a more specific efficient algorithm for calculating ratio of two factorials with arbitrary precision?


Solution

  • You do not need to divide, you just multiply numbers from (2k+1) to (2n), this is obviously can be done in the limits specified;).