%I #11 Mar 01 2019 15:48:36
%S 1,2,2,3,3,2,3,3,4,5,5,2,3,3,5,4,6,2,3,5,2,5,4,3,4,4,4,5,5,3,7,4,6,6,
%T 4,4,2,3,5,5,4,4,7,2,5,5,3,6,4,4,3,8,3,8,5,5,5,5,2,3,3,4,7,7,2,7,3,4,
%U 6,6,3,5,5,4,8,8,6,2,3,3,4,2,7,3,7,7,3,2,5,5,4,9,4,5,9,9,9,3,3,2,3,8
%N Number of steps to fixed point of "k -> k/2 or (k+1)/2 until result is prime", starting with prime(n)+1.
%H Reinhard Zumkeller, <a href="/A039645/b039645.txt">Table of n, a(n) for n = 1..10000</a>
%t f[k_] := Which[PrimeQ[k], k, EvenQ[k], k/2, True, (k+1)/2];
%t a[n_] := Length[FixedPointList[f, Prime[n] + 1]] - 1;
%t Array[a, 102] (* _Jean-François Alcover_, Mar 01 2019 *)
%o (Haskell)
%o a039645 n = snd $ until ((== 1) . a010051 . fst)
%o (\(x, i) -> ((x + 1) `div` 2 , i + 1)) (a000040 n + 1, 1)
%o -- _Reinhard Zumkeller_, Nov 17 2013
%Y Cf. A039634-A039644.
%Y Cf. A010051, A000040, A039641, A039643, A039637.
%K nonn
%O 1,2
%A _Wouter Meeussen_
%E Offset corrected by _Reinhard Zumkeller_, Nov 17 2013
|