Fast computation of binomial coefficients


One problem that arises in computation involving large numbers is precision. In certain situations, the result might be represented by the standard data type, but arithmetic precision might be compromised when dealing with large numbers in the course to the result. Binomial coefficients are an example that suffer from this torment. In the present paper, we review numerical methods to compute the binomial coefficients: Pascal’s recursive method; prime factorization to cancel out terms; gamma function approximation; and a simplified iterative method that avoids loss in precision. Acknowledging that the binomial coefficients might be obtained by a successive convolution of a simple discrete rectangular function, we propose a different approach based on the discrete Fourier transform and another based on its fast implementation. We analyze and compare performance and precision of all of them. The proposed methods overcome the previous ones when computing all coefficients for a given level n, attaining better precision for large values of n.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7


  1. 1.

  2. 2.

    We have also tested the minimum, which gave similar result.

  3. 3.

    Octave documentation states that “by default numeric constants are represented within Octave by IEEE 754 double precision (binary64) floating-point format” [1] which uses 1 bit for sign, 11 to represent the exponent and 52 to the significant (53-bit precision) [12].

  4. 4.

    The bigfloat package in Python is a wrapper for the GNU MPFR library for arbitrary-precision floating-point reliable arithmetic.


  1. 1.

    Eaton, J.W.: Gnu octave (version 5.1.0). (2018)

  2. 2.

    Goetgheluck, P.: Computing binomial coefficients. Am. Math. Mon. 94(4), 360 (1987)

    MathSciNet  Article  Google Scholar 

  3. 3.

    Wolfram Research, Inc. Wolfram—alpha.

  4. 4.

    Keprt, A.: Simple and fast computation of binomial coefficients. In: Wofex 2006, pp. 346–351, VŠB Technical University, Ostrava, Czech Republic, ISBN 80-248-1152-9 (2006)

  5. 5.

    Knuth, D.E.: The Art of Computer Programming: Volume 1: Fundamental Algorithms. Addison Wesley. ISBN 0-201-89683-4 (1997)

  6. 6.

    Koepf, W.: Hypergeometric Summation: An Algorithmic Approach to Summation and Special Function Identities (Advanced Lectures in Mathematics). Vieweg Teubner Verlag. ISBN 3528069503 (1998)

  7. 7.

    Manolopoulos, Y.: Binomial coefficient computation: recursion or iteration?. ACM SIGCSE Bullet. 34(4), 65 (2002).

    Article  Google Scholar 

  8. 8.

    McKeeman, B.: Matlab performance measurement. Technical report, Mathworks. [Online; accessed 03-Feb-2020] (2008)

  9. 9.

    Rolfe, T.: Binomial coefficient recursion. ACM SIGCSE Bullet. 33(2), 35 (2001).

    Article  Google Scholar 

  10. 10.

    Wells, D.: The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books. ISBN 0140080295 (1987)

  11. 11.

    Widrow, B., Kollár, I.: Quantization Noise: Roundoff Error in Digital Computation, Signal Processing, Control, and Communications. Cambridge University Press. ISBN 9780521886710 (2008)

  12. 12.

    Wikipedia contributors. Double-precision floating-point format - Wikipedia, the free encyclopedia. [Online; accessed 17-May-2019] (2019)

Download references

Author information



Corresponding author

Correspondence to Leonardo C. Araujo.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Araujo, L.C., Sansão, J.P.H. & Vale-Cardoso, A.S. Fast computation of binomial coefficients. Numer Algor 86, 799–812 (2021).

Download citation


  • Binomial coefficient
  • Discrete fourier transform
  • fft
  • Numerical analysis