Your constant enemy is yourself.
Dindy Oreeda wrote:
My suggestion is that you use java and the long data type. That is under the int category which means that it accepts/takes whole number only. I'm sure that accepts the huge huge numbers for your factorial.
Paul Clapham wrote:Here's a calculation for you to do before you start: How many digits will there be in the factorial of 10^6?.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Anayonkar Shivalkar wrote:while calculating factorial of 10, memory and processing power required to calculate 7!*8*9*10 is much more than that required to calculate 7!.
Tim Moores wrote:calculating that does not use 8 times as much memory or CPU power
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Tim Moores wrote:Which Java data type can hold a number that large?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Prashant Mathur wrote:
Paul Clapham wrote:Here's a calculation for you to do before you start: How many digits will there be in the factorial of 10^6?.
It would be 8.2639316883 * 10^5,565,708 (approx)
Now tell what next ??
Martin Vajsar wrote:
Prashant Mathur wrote:
Paul Clapham wrote:Here's a calculation for you to do before you start: How many digits will there be in the factorial of 10^6?.
It would be 8.2639316883 * 10^5,565,708 (approx)
Now tell what next ??
Assuming this is true (and I do think it is), I'd like to point out this number exceeds the number of atoms in the known universe by many, many orders of magnitude. So whatever type you'd use to compute this factorial, it cannot fit in memory of any existing computer.
Martin Vajsar wrote:Aehm. I somehow happened to assume the 10^5,565,708 is the number of digits. I shouldn't have read that article about Ackermann function yesterday, I think.
No, it won’t. Java™ suffers an overflow error for i! where i is >12 for an int and >21 (I think) for a long.Dindy Oreeda wrote: . . . My suggestion is that you use java and the long data type. . . . I'm sure that accepts the huge huge numbers for your factorial. . . . Hope it helps.
Prashant Mathur wrote:Need to calculate factorial of huge huge numbers suppose 10,00,000 (10^6)
Jeff Verdegan wrote:We can very easily store this number in a modest amount of memory. It's a 5-million-digit number. Even at 1 byte per digit (rather wasteful) that's only 5 MB.
Actually calculating it, well, that I don't know about.
At least I can work out the rightmost 100000 figures really quickly (assuming you are using decimal arithmetic). Probably using the same technique Martin Vajsar did.Prashant Mathur wrote: . . . It would be 8.2639316883 * 10^5,565,708 (approx) . . .
Campbell Ritchie wrote:At least I can work out the rightmost 100000 figures really quickly (assuming you are using decimal arithmetic). Probably using the same technique Martin Vajsar did.
Campbell Ritchie wrote:So, how did Prashant Mathur work out that figure?
At least I can work out the rightmost 100000 figures really quickly (assuming you are using decimal arithmetic). Probably using the same technique Martin Vajsar did.Prashant Mathur wrote: . . . It would be 8.2639316883 * 10^5,565,708 (approx) . . .
Now, you are counting up to 1000000, and doing arithmetic on a 5000000 digit number. Multiplying such numbers is going to take 5000000 clock cycles, and you do that 1000000 times, so you are looking at quadratic complexity, something in the region of 2,500,000,000,000 clock cycles. Are you sure you are going to take several eternities, Jeff, rather than a few hours?
Jeff Verdegan wrote:Questions like this always get me thinking of Graham's number.
Campbell Ritchie wrote:
Now, you are counting up to 1000000, and doing arithmetic on a 5000000 digit number.
. . . and how long did it take to read the output?Jeff Verdegan wrote: . . . Calculating the factorial of 1,000,000 takes under a minute on my laptop.
No, that’s the Greek budget deficit. And Jurre Hermans will tell you, your head would collapse into a slice of pizza.Jesper de Jong wrote: . . . "If you actually tried to picture Graham's Number in your head, then your head would collapse to form a black hole." . . .
No, I am missing the April Fool thread we usually have hereMartin Vajsar wrote: . . . A small typo here: . . . .
Campbell Ritchie wrote:
. . . and how long did it take to read the output?Jeff Verdegan wrote: . . . Calculating the factorial of 1,000,000 takes under a minute on my laptop.
Consider Paul's rocket mass heater. |