Douglas Hofstadter discovered that the 8th harmonic number equals e.
OK, not really. The following equation cannot possibly be true because the left side is rational and the right side is irrational.
However, Hofstadter showed that the equation does hold if you carry all calculations out to three decimal places.
1.000 0.500 0.333 0.250 0.200 0.167 0.143 0.125 ----- 2.718
The following Python code gets the same result using four-place decimal arithmetic.
Here’s Python code to verify it.
>>> from decimal import * >>> getcontext().prec = 4 >>> sum(Decimal(1)/Decimal(k) for k in range(1, 9)) Decimal('2.718')