Let’s talk more about the leapfrog division.
Because upon closer inspection, you are so right!
At first I could not understand why we need to subtract one from the dividend and then subtract every digit found from nine.
But now I understand it better.
And I assume it is not immediately obvious for everybody.
Btw., I find Greymatters algorithm very elegant, especially now I understand better why it works! So nothing I say should be thought of a criticism.
This is what the algorithm does and is not explained:
In the example of 13/21, 13 gets changed to 12.999999…, which is allowed of course.
This eliminates the need to look ahead like I need to do. So in that sense it is better than what I do.
In the calculation of 1/11, 1/21, 1/31, 1/41, etc. the answer is a repeating string of digits.
And because of that changing 13 into 12.99999… does not give any problems.
The nines of course make subtracting easier.
That is the reason ‘13’ needs to change to ‘12’, and that is also the reason we need to subtract from nine every time.
Keep in mind though that this algorithm works only for expanding fractions.
In the case of 6003/21, one needs to first split the integer part and the fractional part (to get 285 18/21). Mine is more general, since I use it for both.
A funny thing happens if you want to expand it to fractions ending in 2. Then we don’t subtract the digit from nine, but then we need to subtract twice the digit from nine.
If we find digits bigger than 4, then subtracting twice from nine gives problems of course.
If we do this for 32, we see that we need a special way of looking ahead in order to stop. 10/32 = 0.3125. So this is not a continuous stream of digits. Now we need a way to find out that we are done.
Again; with fractions of 31 we subtract each time the digit from nine. Now we need to subtract twice the digit from nine.
10/32
9/3=3r0. (9-23=3)
03/3=1r0 (9-21=7)
07/3=2r1 (9-22=5)
15/3=5r0 (9-25=-1)
0[-1] ???
We have found all digits, so the 0[-1] must indicate a stop, that we are done.
One would expect to stop at ‘00’, i.e. when there is no remainder.
However, 0[-1] actually means ‘no remainder’.
Since we are working with a continuous stream of nines, 00 is actually 0[0,99999999…]. We only concern us with the first 2 digits: 00.
We see this at 10/41.
Using the LeapFrog, we get:
1: 9/4 = 2r1.
2: 17/4=4r1
3: 15/4=3r3
4: 36/4=9r0
5: 00/4=0r0
6: 09/4 = 2r1
7: 17 => repeat from line 2 above
Answer: 0.2439 02439 02439 02439 …
We see that at line 5 we need to continue with ‘00’.
And again, the reason is the line of continuous nines that we are omitting.
‘00’ is actually ‘00.999999’.
In short, we can use the ‘Leapfrog Division II’ only for fractions that end in 1 (11, 21, 31, etc.). For fractions like 12, 22, 32, 13, 23, 33, etc. it is less useful.
That does not make it bad in my opinion. It works great for fractions like 31 and it eliminates the need for looking ahead that I need to do.
And keep in mind that a lot of fractions can be changed into ending in 1:
1/17 = 3/51
Like I said, very elegant for fractions like 31.