%I #14 Dec 16 2018 06:41:03
%S 0,0,1,1,2,0,2,0,3,1,0,3,1,0,4,0,2,0,1,0,0,4,2,1,5,0,0,1,0,0,1,0,2,0,
%T 1,0,0,5,3,0,2,0,0,0,6,0,1,1,1,0,0,0,0,0,2,1,0,0,3,1,0,0,1,0,0,1,6,4,
%U 1,0,0,3,1,0,0,1,1,7,1
%N The minimum number of steps needed to generate prime(n) under the map x -> A060264(x) starting from any x taken from {2,3} or from A164333.
%H V. Shevelev, <a href="https://arxiv.org/abs/0908.2319">On critical small intervals containing primes</a>, arXiv:0908.2319 [math.NT], 2009.
%e a(3) = 1 because prime(3)=5 can be generated in 1 step starting from x=2.
%e a(4) = 1 because prime(4)=7 can be generated in 1 step starting from x=3.
%p # include source from A164333 and A060264 here
%p A164333 := proc(n)
%p if n = 1 then
%p 13;
%p else
%p for a from procname(n-1)+1 do
%p if isA164333(a) then
%p return a;
%p end if;
%p end do;
%p end if;
%p end proc:
%p A164960aux := proc(p,strt)
%p local a,x;
%p if strt > p then
%p return 1000000000;
%p end if;
%p a := 0 ;
%p x := strt ;
%p while x < p do
%p x := A060264(x) ;
%p a := a+1 ;
%p end do;
%p if x = p then
%p return a ;
%p else
%p return 1000000000;
%p end if;
%p end proc:
%p A164960 := proc(n)
%p local p,a,strt,i;
%p p := ithprime(n) ;
%p a := A164960aux(p,2) ;
%p a := min(a,A164960aux(p,3)) ;
%p for i from 1 do
%p strt := A164333(i) ;
%p if strt > p then
%p return a;
%p else
%p a := min(a, A164960aux(p,strt)) ;
%p end if;
%p end do:
%p return a;
%p end proc:
%p seq(A164960(n),n=1..90) ; # _R. J. Mathar_, Oct 29 2011
%t nmax = 100; kmax = nmax + 5;
%t A164333 = Select[Table[{(Prime[k - 1] + 1)/2, (Prime[k] - 1)/2}, {k, 3, kmax}], AllTrue[Range[#[[1]], #[[2]]], CompositeQ] &][[All, 2]]*2 + 1;
%t A164960aux[p_, strt_] := Module[{a, x}, If[strt > p, Return[10^9]]; a = 0; x = strt; While[x < p, x = NextPrime[2 x]; a++]; If[x == p, Return[a], Return[10^9]]];
%t A164960[n_] := Module[{p, a, strt, i}, p = Prime[n]; a = A164960aux[p, 2]; a = Min[a, A164960aux[p, 3]]; For[i = 1, i < 100, i++, strt = A164333[[i]]; If[strt > p, Return[a], a = Min[a, A164960aux[p, strt]]]]; Return[a]];
%t Table[A164960[n], {n, 1, nmax}] (* _Jean-François Alcover_, Dec 13 2017, after _R. J. Mathar_ *)
%Y Cf. A164333.
%K nonn
%O 1,5
%A _Vladimir Shevelev_, Sep 02 2009
%E One term corrected, sequence extended, examples added by _R. J. Mathar_, Oct 29 2011