Calculate factorials in C#

后端 未结 10 1804
日久生厌
日久生厌 2020-12-10 12:10

How can you calculate large factorials using C#? Windows calculator in Win 7 overflows at Factorial (3500). As a programming and mathematical question I am interested in kno

10条回答
  •  轮回少年
    2020-12-10 12:19

    You need a special big-number library for this. This link introduces the System.Numeric.BigInteger class, and incidentally has an example program that calculates factorials. But don't use the example! If you recurse like that, your stack will grow horribly. Just write a for-loop to do the multiplication.

提交回复
热议问题