views:

132

answers:

4

What are some data structures that help me storing and calculating the factorial for numbers with more than 50 digits?

A: 

The simplest way maybe it's to use a char* that can be as long as you need with no particular contraints and it will have easy management of operations..

Of course this is not the most packed approach but it think it can work quite well if you don't really need efficiency.

EDIT: didn't talk about any lib for bigints just because I thought you did want to know how to do it programmatically.

Jack
@Jack thank you very much. Yes I wanted to know programatically
mousey
+5  A: 

Try an Arbitrary Precision integer library like GMP or BigDigits.

drawnonward
Can some one help me how to do this without using any library please
mousey
how do you plan to find the memory to do this operation on arbitrary precision integers? It simply isn't possible.
kaizer.se
@mousy, implementing custom multiplication of integers represented as string is a work of 1-2 hours in most programming languages. Go ahead. I did it once. +1 to @drawnonward for mentioning the arbitrary precision.
Dummy00001
A: 

Seen the number of digits that Jamie computed, I guess the number of bits here would be larger than the estimated number of elementary particles in the universe. So this is another way of stating that your problem just don't has a solution in this world as we know it.

Jens Gustedt
He asked for what you could use, in theory; not sure if it has to be constrained by physical memory limits.
Justin L.
He didn't phrase (or tag) his question as theoretical but asked for help in realizing this task.
Jens Gustedt
+1  A: 

Use the Stirling formula to approximate n! for large n. Best way to store the number should be scientific notation, e.g. 10^(x^y) for really large numbers.

swegi
The only answer that is likely to work.
kaizer.se