A383777 a(n) is the number of steps that n requires to reach 0 under the map: x -> 2*x + 1 if x is even; 0 if x = 1; x - lpf(x) otherwise where lpf(x) is the least prime factor of x. a(n) = -1 if 0 is never reached.
0, 1, 2, 1, 4, 1, 2, 1, 2, 3, 4, 1, 4, 1, 2, 5, 4, 1, 2, 1, 2, 3, 10, 1, 10, 3, 2, 11, 4, 1, 2, 1, 10, 3, 12, 3, 2, 1, 6, 3, 4, 1, 8, 1, 2, 9, 4, 1, 2, 9, 2, 3, 6, 1, 2, 3, 2, 3, 4, 1, 8, 1, 4, 9, 10, 9, 10, 1, 2, 11, 4, 1, 4, 1, 2, 5, 10, 5, 2, 1, 6, 3, 6, 1
Offset: 0
Keywords
Examples
a(10) = 4 because it takes 4 steps for 10 to reach 1 by iterating the map: 10 -> 2*10+1=21 -> 21-3=18 -> 2*18+1=37 -> 37-37=0.
Links
- Paolo Xausa, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
A383777[n_] := Length[NestWhileList[If[OddQ[#], # - FactorInteger[#][[1,1]], 2*# + 1] &, n, # >0 &]] - 1; Array[A383777, 100, 0] (* Paolo Xausa, May 22 2025 *)
-
Python
from sympy import primefactors; mp = lambda x: (0 if x ==1 else x - min(primefactors(x)) if x%2 else 2*x+1) def A383777(n, c = 0): while n != 0: n = mp(n); c += 1 return c
Comments