login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A344383 a(n) is the number of steps needed to reach 1 (or -1 if 1 is never reached) using the following rule: Begin with k = n. On each step, if k is divisible by 9, then divide it by 9; otherwise, if k has not already appeared during the iterative process, concatenate k with the digit d which makes the resulting number divisible by 9, and divide by 9; otherwise, concatenate d with k, and divide by 9. 1
0, 8, 7, 6, 5, 4, 3, 2, 1, 13, 16, 12, 15, 11, 14, 10, 13, 9, 12, 28, 10, 11, 27, 9, 10, 26, 8, 9, 25, 10, 37, 8, 24, 9, 36, 7, 23, 8, 44, 7, 70, 22, 7, 32, 6, 69, 21, 6, 47, 6, 6, 68, 20, 5, 43, 5, 5, 67, 19, 22, 25, 31, 4, 4, 66, 18, 21, 24, 92, 17, 22, 3, 65 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
It appears that all numbers will go to 1 eventually.
Count the iterations to reach 1, starting at k = n, using the following rule for each iteration: If k is divisible by 9, then divide it by 9; otherwise, concatenate the digit d = 9 - (k mod 9) to the end of k and divide by 9, unless k has already appeared during the iterative process; in this case, concatenate d with k and divide by 9.
Least n whose trajectory has no instance of repeated terms is 1; the trajectory of n=31 has 1 repeated term, and that of n=96 has 2 repeated terms. 2 repeated terms is the maximum for 1 <= n <= 2^18. Trajectories for all n in 1..2^20 eventually reach 1. - Michael De Vlieger, May 16 2021
Trajectories for all values of n between 1 and 10^8 eventually reach 1. - Kyle Peterson, May 19 2021
LINKS
Michael De Vlieger, Scatterplot of a(n) for n = 1..2^16.
Michael De Vlieger, Scatterplot of a(n) for n = 1..10^4, showing n with 1 repeated step in red and 2 repeated steps in blue, otherwise, a(n) is plotted in black.
Michael De Vlieger, Log-log scatterplot of a(n) for n = 1..2^18.
Michael De Vlieger, Plot of the steps in a(n) for n = 1..10^4, showing condition A (divisible by 9) in gold, condition B (concatenation of n and d) in light blue, and condition C (repeated step, concatenation of d and n) in red. Magnification is 4X.
EXAMPLE
n=7: start with k=7;
iteration 1: concatenate 7 with 9 - (7 mod 9) = 9 - 7 = 2 to get 72, then divide by 9, yielding k=8;
iteration 2: concatenate 8 with 9 - (8 mod 9) = 9 - 8 = 1 to get 81, then divide by 9, yielding k=9;
iteration 3: divide 9 by 9 to get k=1. k reaches 1 at iteration 3, so a(7)=3.
n=31: k=31 -> 315/9=35 -> 351/9=39 -> 396/9=44 -> 441/9=49 -> 495/9=55 -> 558/9=62 -> 621/9=69 -> 693/9=77 -> 774/9=86 -> 864/9=96 -> 963/9=107 -> 1071/9=119 -> 1197/9=133 -> 1332/9=148 -> 1485/9=165 -> 1656/9=184 -> 1845/9=205 -> 2052/9=228 -> 2286/9=254 -> 2547/9=283 -> 2835/9=315 -> 315/9=35 (*35 occurred at step 1*) -> 135/9=15 -> 153/9=17 -> 171/9=19 -> 198/9=22 -> 225/9=25 -> 252/9=28 -> 288/9=32 -> 324/9=36 -> 36/9=4 -> 45/9=5 -> 54/9=6 -> 63/9=7 -> 72/9=8 -> 81/9=9 -> 9/9=1, so a(31)=37.
MATHEMATICA
Array[-1 + Length@ NestWhile[Append[#1, If[Mod[#2, 9] == 0, #2/9, If[FreeQ[Most@ #1, #2], Select[10*#2 + Range[9], Mod[#, 9] == 0 &][[1]]/9, Select[10^IntegerLength[#2]*Range[9] + #2, Mod[#, 9] == 0 &][[1]]/9]] ] & @@ {#, Last[#]} &, {#}, Last[#] != 1 &] &, 73] (* Michael De Vlieger, May 16 2021 *)
PROG
(Python)
def a(n):
k, prevk, steps, seen = n, n, 0, set()
while k != 1:
q, r = divmod(k, 9)
if r == 0: k = q
elif k not in seen: k = int(str(k) + str(9-r))//9
else: k = int(str(9-r) + str(k))//9
steps, seen, prevk = steps+1, seen|{prevk}, k
return steps
print([a(n) for n in range(1, 74)]) # Michael S. Branicky, Jun 21 2021
CROSSREFS
Sequence in context: A180598 A262703 A031311 * A055119 A265338 A090915
KEYWORD
nonn,easy,base
AUTHOR
Kyle Peterson, May 16 2021
EXTENSIONS
More terms from Michael De Vlieger, May 16 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 00:00 EDT 2024. Contains 371696 sequences. (Running on oeis4.)