Coder's Revolution

Do you want a revolution?

Category Filtering: 'Mathmatics'

Will A Piece Of Paper, Folded 42 Times, Reach The Moon?

So I was at a friend's house Sunday night playing a game when this odd fact came up in conversation:

If you were to fold a piece of paper in half 42 times, it would reach the moon.

Several of those around the table scoffed at this, exclaiming that a single sheet of paper was simply too thin to have its thickness reach any substantial amount after only a few dozen folds.  I pointed out it was entirely possible seeing as how doubling the thickness with each fold would lead to an exponential increase in thickness that would increase slowly at first before quickly getting larger.  My friends were clearly imagining a linear increase in thickness.

I also knew that it is pretty much impossible to fold a single sheet of paper more than about 8 times -- though Myth Busters once folded a giant sheet the size of a football field 10 times. The resulting thickness (after hitting it with a bulldozer) was almost a foot tall, though there was quite a bit of air mixed in with the 1,024 sheets.  The formula for finding out how many of something you'll have after doubling it N number of times is as follows where O is the original number (or size in our case).

o * 2^(n)

A standard sheet of paper is about 0.1 mm so 42 folds would give us this:

0.1 * 2^(42) = 439,804,651,110 mm

That's 440 billion millimeters, or 439,804 kilometers.  The moon on average is 384,400 kilometers from Earth according to Google.  I'd say this checks out.

To help visualize the data, I created a quick spreadsheet and graph that tracks the thickness of the paper for each fold.

 # Folds Thickness (mm) 0 0.10 1 0.20 2 0.40 3 0.80 4 1.60 5 3.20 6 6.40 7 12.80 8 25.60 9 51.20 10 102.40 11 204.80 12 409.60 13 819.20 14 1,638.40 15 3,276.80 16 6,553.60 17 13,107.20 18 26,214.40 19 52,428.80 20 104,857.60 21 209,715.20 22 419,430.40 23 838,860.80 24 1,677,721.6 25 3,355,443.2 26 6,710,886.4 27 13,421,773 28 26,843,546 29 53,687,091 30 107,374,182 31 214,748,365 32 429,496,730 33 858,993,459 34 1,717,986,918 35 3,435,973,837 36 6,871,947,674 37 13,743,895,347 38 27,487,790,694 39 54,975,581,389 40 109,951,162,778 41 219,902,325,555 42 439,804,651,110

And to graph that out in kilometers looks like this:

Generating Primes Revisited: My Modifications To The Sieve of Eratosthenes

In a recent pissing match between ColdFusion and PHP, Jared Rypka-Hauer was demonstrating the performance of a function that generated prime numbers. The discussion really wasn't about the BEST prime generator as much as it was about how much ColdFusion can kick PHP's puny butt all over town. Never the less, I piped up in the comments to ask Jared to compare a prime number generator that I wrote a while back based on the Sieve of Eratosthene. After Jared asked some good questions about how my code worked I figured it was time I stopped high-jacking the comments of the PHP pooper train. I decided to spin off a new post to highlight some significant performance gains I was able to produce.