login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A089754 Smallest prime ending (least significant side) in n if possible else beginning in n. 1

%I #7 Sep 18 2015 05:12:57

%S 11,2,3,41,5,61,7,83,19,101,11,127,13,149,151,163,17,181,19,2003,421,

%T 223,23,241,251,263,127,281,29,307,31,3203,233,347,353,367,37,383,139,

%U 401,41,421,43,443,457,461,47,487,149,503,151,521,53,541,557,563,157,587,59,601,61,6203,163

%N Smallest prime ending (least significant side) in n if possible else beginning in n.

%p read("transforms)"):

%p nleadzero := proc(n,dgs)

%p local ndgs ;

%p if n = 0 then

%p ndgs := 0 ;

%p else

%p ndgs := ilog10(n)+1 ;

%p end if;

%p [op(convert(n,base,10)),seq(0,i=1..dgs-ndgs)]

%p end proc:

%p digcatL2 := proc(L1,L2)

%p digcatL([op(L1),op(L2)]) ;

%p end proc:

%p A089754 := proc(n)

%p local prep,a,dgs ;

%p if isprime(n) then

%p n;

%p elif modp(n,2) = 0 or modp(n,5) = 0 then

%p ndgs := convert(n,base,10) ;

%p for dgs from 1 do

%p for prep from 0 to 10^dgs-1 do

%p a := digcatL2(ListTools[Reverse](ndgs),ListTools[Reverse](nleadzero(prep,dgs))) ;

%p if isprime(a) then

%p return a;

%p end if;

%p end do:

%p end do:

%p else

%p for prep from 1 do

%p a := digcat2(prep,n) ;

%p if isprime(a) then

%p return a;

%p end if;

%p end do:

%p end if;

%p end proc: # _R. J. Mathar_, Sep 18 2015

%Y Cf. A018800, A062584, A068164.

%K base,easy,nonn

%O 1,1

%A _Amarnath Murthy_, Nov 22 2003

%E Corrected by _R. J. Mathar_, Sep 18 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 12:28 EDT 2024. Contains 371969 sequences. (Running on oeis4.)