cp's OEIS Frontend

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.

A349671 Number of iterations x -> (x+1)/2 needed to get 2 or a composite number, when starting with prime(n).

This page as a plain text file.
%I A349671 #13 Nov 27 2021 12:02:56
%S A349671 0,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,1,2,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,
%T A349671 1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,3,1,1,1,
%U A349671 1,1,1,1,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,2,1,1
%N A349671 Number of iterations x -> (x+1)/2 needed to get 2 or a composite number, when starting with prime(n).
%C A349671 a(n) is the least k such that (prime(n) - 1)/2^k + 1 is 2 or a composite number. It follows that a(n) <= v2(prime(n) - 1), v2 = A007814.
%C A349671 For prime(n) != 3, a(n) > 1 if and only if (prime(n)+1)/2 is prime (A005383).
%e A349671 5 -> 3 -> 2 (prime(3) -> prime(2) -> prime(1)), hence a(1) = 0, a(2) = 1, a(3) = 2.
%e A349671 13 -> 7 -> 4 (prime(6) -> prime(4) -> 4), hence a(4) = 1, a(6) = 2.
%e A349671 73 -> 37 -> 19 -> 10 (prime(21) -> prime(12) -> prime(8) -> 10), hence a(8) = 1, a(12) = 2, a(21) = 3.
%t A349671 a[n_] := -1 + Length @ NestWhileList[(# + 1)/2 &, Prime[n], # == 1 || (OddQ[#] && PrimeQ[#]) &]; Array[a, 90] (* _Amiram Eldar_, Nov 27 2021 *)
%o A349671 (PARI) a(n) = my(p=prime(n), k=0); while(isprime(m = (p-1)>>k + 1) && m != 2, k++); k
%Y A349671 Cf. A181697, A181715, A349670, A007814, A005383.
%K A349671 nonn
%O A349671 1,3
%A A349671 _Jianing Song_, Nov 24 2021