Skip to content

Instantly share code, notes, and snippets.

@lxndrdagreat
Created May 23, 2017 17:51
Show Gist options
  • Save lxndrdagreat/ce623ac6a221c845722b5bee2dd8d529 to your computer and use it in GitHub Desktop.
Save lxndrdagreat/ce623ac6a221c845722b5bee2dd8d529 to your computer and use it in GitHub Desktop.
Computes and prints out some interesting math dealing with stacking pieces of paper.
# Pieces of Paper
#
# Take a piece of paper (roughly 0.1mm in thickness),
# double it 100 times.
from decimal import *
paper = Decimal('0.1')
total_pieces_of_paper = 1
for i in range(0, 100):
paper *= Decimal('2')
total_pieces_of_paper *= 2
print('{}: {}mm'.format(i+1, paper))
in_meters = paper / Decimal('1000')
if in_meters > 0.5:
print(' {}m'.format(in_meters))
in_km = in_meters / Decimal('1000')
if in_km > 0.5:
print(' {}km'.format(in_km))
trips_to_moon = in_km / Decimal('384400') / Decimal('2')
print(' {0:.2f} round trips to the moon'.format(trips_to_moon))
trips_to_sun = in_km / Decimal('150000000') / Decimal('2')
print(' {0:.2f} round trips to the sun'.format(trips_to_sun))
size_of_galaxy = in_km / Decimal('1000000000000000000')
print(' {0:.2f} times the size of the Milky Way'.format(size_of_galaxy))
print()
print('{} total pieces of paper'.format(total_pieces_of_paper))
total_pieces_of_paper = Decimal(total_pieces_of_paper)
war_and_peace = total_pieces_of_paper / Decimal('587287')
print('Every word in "War and Peace", {} times'.format(war_and_peace))
reams = total_pieces_of_paper / Decimal('500')
print('{} reams'.format(reams))
trees = reams / Decimal('16.67')
print('{} trees'.format(trees))
@lxndrdagreat
Copy link
Author

Some of the output:

  • 126765060022822940149670.3205 km
  • 164886914701902887.81 round trips to the moon
  • 422550200076076.47 round trips to the sun
  • 126765.06 times the size of the Milky Way
  • 1267650600228229401496703205376 total pieces of paper
  • 2535301200456458802993406411 reams
  • 152087654496488230533497685.1 trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment