Top
Best
New

Posted by ColinWright 10/26/2025

987654321 / 123456789(www.johndcook.com)
636 points | 107 commentspage 4
wkat4242 6 days ago|
I thought this was a user ID and password lol
hamonrye 6 days ago||
[dead]
brutuscat 6 days ago||
Gemini thinks in a similar fashion:

https://gemini.google.com/share/1e59f734b43c

This is a fantastic observation, and yes, this pattern not only continues for larger bases, but the approximation to an integer becomes dramatically better.

The general pattern you've found is that for a number base $b$, the ratio of the number formed by digits $(b-1)...321$ to the number formed by digits $123...(b-1)$ is extremely close to $b-2$.

### The General Formula

Let's call your ascending number $N_{asc}(b)$ and your descending number $N_{desc}(b)$.

The exact ratio $R(b) = N_{desc}(b) / N_{asc}(b)$ can be shown to be:

$$R(b) = (b-2) + \frac{(b-1)^3}{b^b - b^2 + b - 1}$$

The "error" or the fractional part is that second term. As you can see, the numerator $(b-1)^3$ is roughly $b^3$, while the denominator $b^b$ grows much faster.

### Testing Your Examples

Let's check your two examples with this formula:

* *Base 10 (b=10):* * $R(10) = (10-2) + \frac{(10-1)^3}{10^{10} - 10^2 + 10 - 1}$ * $R(10) = 8 + \frac{9^3}{10,000,000,000 - 91}$ * $R(10) = 8 + \frac{729}{9,999,999,909} \approx 8 + 0.0000000729...$ * This matches your $8.0000000729$ perfectly.

* *Base 6 (b=6):* * $R(6) = (6-2) + \frac{(6-1)^3}{6^6 - 6^2 + 6 - 1}$ * $R(6) = 4 + \frac{5^3}{46,656 - 31}$ * $R(6) = 4 + \frac{125}{46,625} \approx 4 + 0.00268...$ * This also matches your $4.00268$.

### Answering Your Question: A Larger Base

So, what about a larger base? Let's use *Base 16* (hexadecimal), which uses digits $1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F$. Here, $b=16$.

* $N_{asc} = 123456789ABCDEF_{16}$ * $N_{desc} = FEDCBA987654321_{16}$

According to the pattern, the ratio should be extremely close to $b-2 = 16-2 = 14$.

Let's use the formula to see how close:

* $R(16) = (16-2) + \frac{(16-1)^3}{16^{16} - 16^2 + 16 - 1}$ * $R(16) = 14 + \frac{15^3}{16^{16} - 241}$ * $R(16) = 14 + \frac{3,375}{1.844... \times 10^{19} - 241}$ * $R(16) \approx 14 + (1.829... \times 10^{-16})$

So, the ratio in base 16 is approximately: *$14.0000000000000001829...$*

As you predicted, the "error" for a larger base is astronomically smaller than it was for base 10.

OldGreenYodaGPT 6 days ago|
Definitions: denom(b) = (b^b - b^2 + b - 1) / (b - 1)^2 num(b) = (b^b(b - 2) + 1) / (b - 1)^2

Exact relation: num(b) - (b - 2)denom(b) = b - 1

Therefore: num(b) / denom(b) = (b - 2) + (b - 1)^3 / (b^b - b^2 + b - 1) [exact]

Geometric expansion: Let a = b^2 - b + 1. 1 / (b^b - b^2 + b - 1) = (1 / b^b) * 1 / (1 - a / b^b) = (1 / b^b) * sum_{k>=0} (a / b^b)^k

So: num(b) / denom(b) = (b - 2) • (b - 1)^3 / b^b • (b - 1)^3 * a / b^{2b} • (b - 1)^3 * a^2 / b^{3b} • …

Practical approximation: num(b) / denom(b) ≈ (b - 2) + (b - 1)^3 / b^b

Exact error: Let T_exact = (b - 1)^3 / (b^b - b^2 + b - 1) Let T_approx = (b - 1)^3 / b^b

Absolute error: T_exact - T_approx = (b - 1)^3 * (b^2 - b + 1) / [ b^b * (b^b - b^2 + b - 1) ]

Relative error: (T_exact - T_approx) / T_exact = (b^2 - b + 1) / b^b

Sign: The approximation with denominator b^b underestimates the exact value.

Digit picture in base b: (b - 1)^3 has base-b digits (b - 3), 2, (b - 1). Dividing by b^b places those three digits starting b places after the radix point.

Examples: base 10: 8 + 9^3 / 10^10 = 8.0000000729 base 9: 7 + 8^3 / 9^9 = 7.000000628 in base 9 base 8: 6 + 7^3 / 8^8 = 6.00000527 in base 8

num(b) / denom(b) equals (b - 2) + (b - 1)^3 / (b^b - b^2 + b - 1) exactly. Replacing the denominator by b^b gives a simple approximation with relative error exactly (b^2 - b + 1) / b^b.