A039637 Number of steps to fixed point of "n -> n/2 or (n+1)/2 until result is prime".
1, 1, 1, 2, 1, 2, 1, 3, 2, 2, 1, 3, 1, 2, 4, 4, 1, 3, 1, 3, 2, 2, 1, 4, 2, 2, 3, 3, 1, 5, 1, 5, 2, 2, 4, 4, 1, 2, 4, 4, 1, 3, 1, 3, 2, 2, 1, 5, 3, 3, 3, 3, 1, 4, 4, 4, 2, 2, 1, 6, 1, 2, 6, 6, 3, 3, 1, 3, 5, 5, 1, 5, 1, 2, 3, 3, 5, 5, 1, 5, 2, 2, 1, 4, 2, 2, 4, 4, 1, 3, 3, 3, 2, 2, 6, 6, 1, 4, 4, 4, 1, 4
Offset: 1
Keywords
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
a039637 1 = 1 a039637 n = snd $ until ((== 1) . a010051 . fst) (\(x, i) -> ((x + 1) `div` 2 , i + 1)) (n, 1) -- Reinhard Zumkeller, Nov 17 2013
-
Mathematica
upplist[ n_Integer ] := Length/@Drop[ FixedPointList[ If[ EvenQ[ # ]&>2, #/ 2, If[ PrimeQ[ # ]||(#===1), #, (#+1)/2 ] ]&, n, 20 ], -1 ]
Extensions
Offset corrected by Reinhard Zumkeller, Nov 17 2013