What are some data structures that help me storing and calculating the factorial for numbers with more than 50 digits?
views:
132answers:
4The 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.
Try an Arbitrary Precision integer library like GMP or BigDigits.
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.
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.