The Ghost Iteration


El Greco, The Vision of Saint John (1610-1614)

Take an integer like 2019.
We will call "ghost" the concatenation of the absolute differences of its digits.
The ghost of 2019 is thus 218.
(We don't keep the possible leading zeros of a ghost: for example, the ghost of 1186 is 72 (not 072).

The A rule:
If a ghost is even, add it to the starting integer. Else subtract it. And iterate from there.

  2019
+  218   <-- first ghost 
------
  2237
+   14   <-- second ghost
------
  2251
+   34   <-- third ghost
------
  2285
-   63   <-- fourth ghost
------
  2222
=    0   <-- last and zero ghost

It seems that every integer will have a zero ghost at the end of the process. And this seems to be true even with the opposite B rule.

The B rule:
If a ghost is odd, add it to the starting integer. Else subtract it. And iterate from there.

  2019
-  218   <-- first ghost 
------
  1801
+  781   <-- second ghost
------
  2582
-  336   <-- third ghost
------
  2246
-   22   <-- fourth ghost
------
  2224
-    2   <-- fifth ghost
------
  2222
=    0   <-- last and zero ghost

Now, how could we submit this Ghost Iteration to the OEIS?  We must note that a single-digit integer has no ghost: 8, for instance, lives by itself.
Let's see what the A rule produces with the successive integers > 9:
"If a ghost is even, add it to the starting integer. Else subtract it. And iterate from there".

10 - 1 = 9 --> END (single digit)
11 --> zero ghost = END
12 - 1 = 11 (END, see above)
13 + 2 = 15
         15 + 4 = 19
                  19 + 8 = 27
                           27 - 5 = 22 (zero ghost, END)
14 - 3 = 11 (zero ghost, END)
15 (see above)
16 - 5 = 11 (zero ghost, END)
17 + 6 = 23
         23 - 1 = 22 (zero ghost, END)
18 - 7 = 11 (zero ghost, END)
19 (see above)
20 + 2 = 22 (zero ghost, END)
21 - 1 = 20 (see above)
22 (zero ghost, END)
23 - 1 = 22 (zero ghost, END)
24 + 2 = 26
         26 + 4 = 30
                  30 - 3 = 27
                           27 - 5 = 22 (zero ghost, END)
25 - 3 = 22 (zero ghost, END)
26 (see above)
27 (see above)
28 + 6 = 34
         34 - 1 = 33 (zero ghost, END)
29 - 7 == 22 (zero ghost, END)
30 (see above)
31 + 2 = 33 (zero ghost, END)
etc.

We could assign to every n > 9 the number of iterations before reaching an END:

10 ~ 1
11 ~ 0
12 ~ 1
13 ~ 4
14 ~ 1
15 ~ 3
16 ~ 1
17 ~ 2
18 ~ 1
19 ~ 2
20 ~ 1
21 ~ 1
22 ~ 0
23 ~ 1 
24 ~ 4
25 ~ 1
26 ~ 3
27 ~ 1
28 ~ 2
29 ~ 1
30 ~ 2
31 ~ 1
etc.

This sequence could be defined like that:
> Number of steps such that n+9 reaches an END in the Ghost Iteration (see the Comments section).
S = 1,0,1,4,1,3,1,2,1,2,1,1,0,1,4,1,3,1,2,1,2,1,...
Yes, there is a pattern there:
S = 1,0,1,4,1,3,1,2,1,2,1,1,0,1,4,1,3,1,2,1,2,1...

A similar sequence could be submitted for the B rule.

Note that if an integer enters a loop, it will have no ghost (see below); the S sequence should thus have a minus one (-1) value for such ns.
Last word: some integers have many ancestors, no matter the rule — but this is another (fun) story.

Best,
É.
____________________
11th nov 2019 update.

Maximilian Hasler was kind enough to put the A rule here, and the B rule there (OEIS).
Harvey P. Dale was the first to spot an integer entering a loop (thus having no 'zero ghost'): 11090.
This integer can produce an infinite famiy of  such 'loopers' by preceding 11090 by any quantity of 1-repunits: 111090, 1111090, 11111090, etc.
More loopers were found a few hours later by Maximilian and Lars Blomberg (see below)
____________________
11th nov 2019 second update

Maximilian Hasler has put a lot of stuff on the OEIS (follow the links, read and enjoy!-)
Here is the « Irregular table whose rows list the nontrivial cycles of the ghost iteration A329200 [rule A] starting with the smallest member »:
10891, 12709, 11130, 11107, 11090, 43600, 44960, 45496, 44343, 44232, 44021, 74780, 78098, 76207, 75800, 78180, 79958, 77915, 78199, 79979, 82001, 110891, 112709, 111130, 111107, 111090, 180164, 258316, 224791, 227119, 232727, 221172, 220107, 217990, 201781,...

Here is the « Irregular table whose rows list the nontrivial cycles of the ghost iteration A329201 [rule B], starting with the smallest member »:
8290, 8969, 9102, 17998, 24199, 21819, 20041, 22084, 21800, 20020, 21901, 23792, 25219, 54503, 55656, 55767, 55978, 56399, 55039, 87290, 88869, 88892, 88909, 89108, 108070, 126947, 141300, 221901, 223792, 225219, 554503, 555656, 555767, 555978, 556399, 555039,...

Here is a list of 107 loopers (rule A) sent to me by Lars Blomberg , confirming Harvey's and Maximilian's computations:

10891, 11090, 11107, 11130, 12709, 43600, 44021, 44232, 44343, 44960, 45496, 74780, 75800, 76207, 77915, 78098, 78180, 78199, 79958, 79979, 82001, 110891, 111090, 111107, 111130, 112709, 180164, 201781, 217990, 220107, 221172, 224791, 227119, 232727, 258316, 443600, 444021, 444232, 444343, 444960, 445496, 774780, 776207, 778098, 858699, 873052, 891929, 1110891, 1111090, 1111107, 1111130, 1112709, 3270071, 3301514, 3427147, 4381182, 4412625, 4443600, 4444021, 4444232, 4444343, 4444960, 4445496, 4538258, 5492293, 5523736, 5649369, 7774780, 7776207, 7778098, 8858699, 8873052, 8891929, 11110891, 11111090, 11111107, 11111130, 11112709, 33270071, 33301514, 33427147, 44381182, 44412625, 44443600, 44444021, 44444232, 44444343, 44444960, 44445496, 44538258, 55492293, 55523736, 55649369, 77774780, 77776207, 77778098, 85869922, 87305285, 88858699, 88873052, 88891929, 89192992, 111110891, 111111090, 111111107, 111111130, 111112709,...

I couln't find any integer that would loop under both rules A and B, though. Looks impossible to me...
Again, many thanks to all!
Best,
É.



Commentaires

Posts les plus consultés de ce blog

A square for three (chess)

Le tripalin se présente

Some strings au cinéma Galeries