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.

A164960 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.

Original entry on oeis.org

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, 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, 1, 0, 0, 3, 1, 0, 0, 1, 1, 7, 1
Offset: 1

Views

Author

Vladimir Shevelev, Sep 02 2009

Keywords

Examples

			a(3) = 1 because prime(3)=5 can be generated in 1 step starting from x=2.
a(4) = 1 because prime(4)=7 can be generated in 1 step starting from x=3.
		

Crossrefs

Cf. A164333.

Programs

  • Maple
    # include source from A164333 and A060264 here
    A164333 := proc(n)
            if n = 1 then
                    13;
            else
                    for a from procname(n-1)+1 do
                            if isA164333(a) then
                                    return a;
                            end if;
                    end do;
            end if;
    end proc:
    A164960aux := proc(p,strt)
            local a,x;
            if strt > p then
                    return 1000000000;
            end if;
            a := 0 ;
            x := strt ;
            while x < p do
                    x := A060264(x) ;
                    a := a+1 ;
            end do;
            if x = p then
                    return a ;
            else
                    return 1000000000;
            end if;
    end proc:
    A164960 := proc(n)
            local p,a,strt,i;
            p := ithprime(n) ;
            a := A164960aux(p,2) ;
            a := min(a,A164960aux(p,3)) ;
            for i from 1 do
                    strt := A164333(i) ;
                    if strt > p then
                            return a;
                    else
                            a := min(a, A164960aux(p,strt)) ;
                    end if;
            end do:
            return a;
    end proc:
    seq(A164960(n),n=1..90) ; # R. J. Mathar, Oct 29 2011
  • Mathematica
    nmax = 100; kmax = nmax + 5;
    A164333 = Select[Table[{(Prime[k - 1] + 1)/2, (Prime[k] - 1)/2}, {k, 3, kmax}], AllTrue[Range[#[[1]], #[[2]]], CompositeQ] &][[All, 2]]*2 + 1;
    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]]];
    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]];
    Table[A164960[n], {n, 1, nmax}] (* Jean-François Alcover, Dec 13 2017, after R. J. Mathar *)

Extensions

One term corrected, sequence extended, examples added by R. J. Mathar, Oct 29 2011