Earlier quoted context omitted.
But it would lack a 9998.
then i suppose we need 1/9999800001 !
Another way to get the real consecutive numbers is to make a rest so we avoid that annoying increment at the end:
1/998001 - 1e-1000
61–70 of 99 posts
Incidentally, understanding how this works is helpful to programmers. If you know why this happens, you'll know why you can't write: double x = 0.1; and get something that works.
> you can't write ... and get something that works. That's taking things a bit far, isn't it? Sure, you can't exactly express 0.1 as a double - but you can get many things that work really well using the approximation.
1/(b-1)^2 = 0.0123456... (where '1', '2'.. are base b digits).
The original post is this fact in base 1000.
Proof for any base: 1/(b-1) = 1/b + 1/b^2 + 1/b^3 + .. = 0.11111.. (base b).
So 1/(b-1)^2 = 0.11111.. * (1/b + 1/b^2 + 1/b^3 + ...) = 0.012345... QED.
Richard Feynman beat us all to the punch here by noticing that 1/243 = 0.004115226337..., a fact which he wrote in a letter from a secret lab to someone in the outside world, and which put him under suspicion of sending secret messages! That gem of a fraction turns out to be a result of the above stuff as 1/243 = 111 * (1/999^2) + 4/999.
Here's a slightly more detailed explanation:
... and 1/9999999800000001 = .00000000 00000001 00000002 00000003 00000004 00000005 00000006 ... 99999996 99999997 99999999 ...repeating Basically, the pattern is 1 over some number of 9s, followed by an 8, followed by the same number of 0s, followed by a 1. So, 1/81, 1/9801, 1/998001, 1/99980001, 1/9999800001, etc.
it's 9x9, 99x99, 999x999, 9999x9999,....
Love the trick with how this can be done via differentiating the equation:
1 + r + r^2 + ... = 1/(1-r)
The .001 repeating = 1/999, simplify, voila.
;Here is my version in Common Lisp
;Supply your own flatten function
;or borrow one from let-over-lambda or something
;http://letoverlambda.com/lol.lisp
(defun long-div (dividend divisor depth)
(cond
((> depth 0)
(flatten (list
(truncate (/ dividend divisor))
(long-div (* 10 (mod dividend divisor))
divisor (- depth 1)))))
(t ())))