How long does it take a computer to count up to one trillion?
This is a question that came after a discussion with a colleague of mine at the university. He was telling me about some company worth over 20 trillion dollars – and he just couldn’t imagine how that much money would look like in cash. Just to get an idea of it we calculated how many hundred dollar bills it would take to circle the Earth once – the answer was I believe around 240.000.000 meaning around 24 billion US dollars. That’s a lot of money. How much would it take a person to count that much money? Well, I can’t say for sure.
What we can do to get an idea is see how much it would take a computer to count up to that value. To simply iterate, no other action in between. For that I’ve wrote a simple piece of code which measures how much it takes to count up to one million and then does some simple math to estimate how much it would take to count up to different values and then displays the results in a friendly way using a method courtesy of StackOverflow.
The results are interesting. And the answer is: it depends on your machine. Even on the same machine you will get different results depending on the load. But let’s look at mine for a bit:
- one billion (9 zeros) is being reached fast – 15 seconds
- but to get to one trillion (12 zeros) – the difference is amazing – 4 hours and 10 minutes. Basically 1000 times more.
- the differences get even more impressive as we go up to quadrillions (15 zeros) which would take 173 days and then quintillions (18 zeros) which would take 475 years
- the last one for which I did the math is one sextillion (21 zeros) and get ready – it would take my laptop exactly 7708 years, 292 days, 6 hours, 43 minutes and 52 seconds to iterate up to that value.