I'm using ulong for the factorial of 100, but it still overflows

前端 未结 2 2026
礼貌的吻别
礼貌的吻别 2021-01-29 06:34

So my task is: I have the number 100, and I have to print the sum of the digits of it\'s factorial.

So I wrote the code, found a nice way of summing the digits but my c

2条回答
  •  抹茶落季
    2021-01-29 07:01

    I've been playing around with my own large math research projects. You can use the .NET BigInteger class (under System.Numerics), but it's not the most efficient library out there.

    If you aren't stuck on .NET, I'd suggest using the GNU Multiple Precision Arithmetic Library (https://gmplib.org/). It is both far faster and has far more functionality. You will need to study the docs to learn to use it properly.

    Ports of it do exist, though I haven't seen a great port from an API perspective - do a search on Nuget.

提交回复
热议问题