This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A349670 #12 Nov 27 2021 12:02:41 %S A349670 0,1,1,2,2,1,1,1,3,1,1,1,1,1,4,1,2,1,1,1,1,1,2,1,1,1,1,2,1,1,1,1,1,1, %T A349670 1,1,1,1,3,1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1, %U A349670 2,1,1,3,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1 %N A349670 Number of iterations x -> (x-1)/2 needed to get 1, 2 or a composite number, when starting with prime(n). %C A349670 a(n) is the least k such that (prime(n) + 1)/2^k - 1 is 1, 2 or a composite number. It follows that a(n) <= v2(prime(n) + 1), v2 = A007814. %C A349670 For prime(n) != 5, a(n) > 1 if and only if prime(n) is a safe prime (A005385). %e A349670 47 -> 23 -> 11 -> 5 -> 2 (prime(15) -> prime(9) -> prime(5) -> prime(3) -> prime(1)), hence a(1) = 0, a(3) = 1, a(5) = 2, a(9) = 3, a(15) = 4. %e A349670 7 -> 3 -> 1 (prime(4) -> prime(2) -> 1), hence a(2) = 1, a(4) = 2. %e A349670 59 -> 29 -> 14 (prime(17) -> prime(10) -> 14), hence a(10) = 1, a(17) = 2. %t A349670 a[n_] := -1 + Length @ NestWhileList[(# - 1)/2 &, Prime[n], OddQ[#] && PrimeQ[#] &]; Array[a, 90] (* _Amiram Eldar_, Nov 27 2021 *) %o A349670 (PARI) a(n) = my(p=prime(n), k=0); while(isprime(m = (p+1)>>k - 1) && m != 2, k++); k %Y A349670 Cf. A181697, A181715, A349671, A007814, A005385. %K A349670 nonn %O A349670 1,4 %A A349670 _Jianing Song_, Nov 24 2021