Working with very large integers in C #

Does anyone know how I can calculate very large integers in C #

I am trying to calculate factorial of numbers, for example.

5! = 5 * 4 * 3 * 2 * 1 = 120

with small numbers this is not a problem, but trying to calculate the factorial of the largest unsigned int value, which is 4,294,967,295, seems impossible.

I looked at the BigInteger class, but it doesn't seem to do what I need

any help would be greatly appreciated

+3
source share
9 answers

4294967295! = 10 ^ (10 ^ 10.597) ~ 10 ^ (40000000000) This value requires about 40 GB of RAM, even if you find a BigInteger implementation for C #!

P.S. , , , 9 4 , 18 .

+5

uint.MaxValue .

, 8.2639316883... × 10 ^ 5,565,708. , .

, . ? ?

+10

-, , uint.MaxValue . , , , , .

A BigInteger , , 1 000 000 ( ). . () .NET, 3.5, . CodeProject, -, . .NET 4.0, Microsoft, , BigInteger System.Numerics BCL. BigInteger, .NET 4.0 ( CodeProject), - .

, , , BigInteger, , , , , , , .

+5

, ? - .

(2 ^ 32-1) , 16 .

, , . , , , .

- Euler, , , , , .

+2

. , . . .

0

J # redist, java.math.BigInteger, vjslib.

0

, , , 1 (, 98 * 98 * 97, ).

0

Here . The fastest of them, directly from the Factorial is Peter Lushny.

0
source

Source: https://habr.com/ru/post/1709448/


All Articles