Skip to content(if available)orjump to list(if available)

987654321 / 123456789

987654321 / 123456789

44 comments

·October 26, 2025

tetris11

I like calculator quirks like this. I remember as a kid playing with the number pad and noticing a geometric center of mass in number sequences

    ┌───┬───┬───┐
    │ 7 │ 8 │ 9 │
    ├───┼───┼───┤
    │ 4 │ 5 │ 6 │
    ├───┼───┼───┤
    │ 1 │ 2 │ 3 │
    ├───┼───┼───┤
    │ 0 │ . │   │
    └───┴───┴───┘
I remember seeing that (14787 + 36989) / 2 would produce 25888, in that the mean of geometric shape traced by the two sequences would average out in the middle like that

nashashmi

14789 + 36987 / 2 would do the same thing. Why trace back?

dfee

So would 147 and 369. As it’s just an average, per digit, I’m not sure this is very interesting.

gowld

Being curious is delightful.

tetris11

Just to show that you could - 14861 and 36843 gives 25852

jedberg

This was by far the most interesting part to me. I've never considered that code and proofs can be so complimentary. It would be great if someone did this for all math proofs!

"Why include a script rather than a proof? One reason is that the proof is straight-forward but tedious and the script is compact.

A more general reason that I give computational demonstrations of theorems is that programs are complementary to proofs. Programs and proofs are both subject to bugs, but they’re not likely to have the same bugs. And because programs made details explicit by necessity, a program might fill in gaps that aren’t sufficiently spelled out in a proof."

Joker_vD

Somewhat interesting, 123456789 * 8 is 987654312 (the last two digits are swapped). This holds for other bases as well: 0x123456789ABCDEF * 14 is 0xFEDCBA987654312.

Also, adding 123456789 to itself eight times on an abacus is a nice exercise, and it's easy to visually control the end result.

andyjansson

Another interesting thing is that these seem to work:

base 16: 123456789ABCDEF~16 * (16-2) + 16 - 1 = FEDCBA987654321~16

base 10: 123456789~10 * (10-2) + 10 - 1 = 987654321~10

base 9: 12345678~9 * (9-2) + 9 - 1 = 87654321~9

base 8: 1234567~8 * (8-2) + 8 - 1 = 7654321~8

base 7: 123456~7 * (7-2) + 7 - 1 = 654321~7

base 6: 12345~6 * (6-2) + 6 - 1 = 54321~6

and so on..

or more generally:

base n: sequence * (n - 2) + n - 1

alyxya

I like to think of 0.987654... and 0.123456... as infinite series which simplify to 80/81 and 10/81, hence the ~8 ratio.

oersted

I didn't get where this comes from until I saw the second answer from the StackOverflow question another commenter shared.

https://math.stackexchange.com/a/2268896

Apparently 1/9^2 is well known to be 0.12345679(012345679)...

EDIT: Yes it's missing the 8 (I wrote it wrong intially): https://math.stackexchange.com/questions/994203/why-do-we-mi...

Interesting how it works out but I don't think it is anywhere close to as intuitive as the parent comment implies. The way its phrased made me feel a bit dumb because I didn't get it right away, but in retrospect I don't think anyone would reasonably get it without context.

alyxya

It actually skips the 8 in its repeating decimal. It’s better to think of 1/9^2 as the infinite sum of k * 10^-k for all positive integers k. The 8 gets skipped because you have something like ...789(10)(11)... where the 1 from the “10” and “11” digits carry over, increment the 9 digit causing another carry, so the 8 becomes a 9.

iso1631

9^2 is 81

1/81 is 0.012345679012345679....

no 8 in sight

madcaptenor

The 8 is there but then it's followed by a 9 and a 10, and the carry from the 10 ends up bumping it up.

Stolpe

Care to elaborate? Why does 0.987654 simplify to 80/81 and 0.123456 to 10/81?

madcaptenor

.123456... = x + 2 x^2 + 3 x^3 + ... with x = 1/10.

Then you have (x + 2 x^2 + 3 x^3 + ...) = (x + x^2 + x^3 + x^4 + ...) + (x^2 + x^3 + x^4 + x^5 + ...) + (x^3 + x^4 + x^5 + x^6 + ...) (count the number of occurrences of each power of x^n on the right-hand side)

and from the sum of a geometric series the RHS is x/(1-x) + x^2/(1-x) + x^3/(1-x) + ..., which itself is a geometric series and works out to x/(1-x)^2. Then put in x = 1/10 to get 10/81.

Now 0.987654... = 1 - 0.012345... = 1 - (1/10) (10/81) = 1 - 1/81 = 80/81.

gowld

Don't need the clutter of infinite series and polynomials:

    1/9 = 0.1111...

    1/81 = 1/9 * 1/9 = 0.111... * 0.111... =

    Sum of:
       0.0111...
       0.00111...
       0.000111...
       ...
    
    =  0.012345...

gus_massa

I don't know who downvoted this, but it's correct.

The use of series is a little "sloppy", but x + 2 x^2 + 3 x^3 + ... has absolute uniform convergence when |x|<r<1, even more importantly that it's true even for complex numbers |z|<r<1.

The super nice property of complex analysis is that you can be almost ridiculously "sloppy" inside that open circle and the Conway book will tell you everything is ok.

[I'll post a similar proof, but mine use -1/10 and rounding, so mine is probably worse.]

alyxya

If you set x = 0.123456..., then multiplying it by (10 - 1) gives 9x = 1.111111..., and multiplying it by (10 - 1) again gives 81x = 10, or x = 10/81. I’m not writing things formally here but that’s the rough idea, and you can do the same procedure with 0.987654... to get 80/81.

msuvakov

Why the b > 2 condition? In the b=2 case, all three formulas also work perfectly, providing a ratio of 1. And this is interesting case where the error term is integer and the only case where that error term (1) is dominant (b-2=0), while the b-2 part dominates for larger bases.

listeria

in the b=2 case, you get:

  1 / 1 = 1 = b - 1
  1 % 1 = 0 = b - 2
they are the other way around, see for example the b=3 case:

  21 (base 3) = 7
  12 (base 3) = 5
  7 / 5 = 1 = b - 2
  7 % 5 = 2 = b - 1

throw0101c

See perhaps various "What every programmer / CSist should know about floating-point arithmetic" papers and articles:

* David Goldberg, 1991: https://dl.acm.org/doi/10.1145/103162.103163

* 2014, "Floating Point Demystified, Part 1": https://blog.reverberate.org/2014/09/what-every-computer-pro... ; https://news.ycombinator.com/item?id=8321940

* 2015: https://www.phys.uconn.edu/~rozman/Courses/P2200_15F/downloa...

MrOrelliOReilly

As someone who has recently been fighting bugs from representing very simple math with floats... thank you!

ok123456

For the even bases, the "error" appears to be https://oeis.org/A051848.

pp = lambda x : denom(x)/ (num(x) - denom(x)*(x - 2))

[pp(2),pp(4),pp(6),pp(8)]

[1.0, 9.0, 373.0, 48913.0]

madcaptenor

And if you see the description there it traces back to https://oeis.org/A023811, which is more obviously relevant

danielbarla

I also spent hours messing around with calculators as a kid. I recall noticing that:

11 * 11 = 121

111 * 111 = 12321

1111 * 1111 = 1234321

and so on, where the largest digit in the answer is the number of digits in the multiplicands.

trotro

Feels like a Temu version of Ramanujan's constant [0].

[0] https://mathworld.wolfram.com/RamanujanConstant.html

ozb

ukuina

That question was asked 8 years ago. Coincidence? I think not!

yohbho

For smaller bases, does this converge to base - 1 ?

Base 3: 21/12 = 7/5(dec.)

Base 2: 1/1 = 1

Base 1: |/| = 1 (thinking |||| = 4 etc.)

MontyCarloHall

In a similar vein, e^pi - pi = 19.9990999792, as referenced in this XKCD: https://xkcd.com/217/

zkmon

Also, (-1)^(-i) - pi = 19.999... ;)

madcaptenor

Not really in a similar vein, because there's actually a good reason for this to be very close to an integer whereas there is no such reason for e^pi - pi.

tempfile

No known reason :-)

null

[deleted]