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.

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

This page as a plain text file.
%I A089754 #7 Sep 18 2015 05:12:57
%S A089754 11,2,3,41,5,61,7,83,19,101,11,127,13,149,151,163,17,181,19,2003,421,
%T A089754 223,23,241,251,263,127,281,29,307,31,3203,233,347,353,367,37,383,139,
%U A089754 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 A089754 Smallest prime ending (least significant side) in n if possible else beginning in n.
%p A089754 read("transforms)"):
%p A089754 nleadzero := proc(n,dgs)
%p A089754     local ndgs ;
%p A089754     if n = 0 then
%p A089754         ndgs := 0 ;
%p A089754     else
%p A089754         ndgs := ilog10(n)+1 ;
%p A089754     end if;
%p A089754     [op(convert(n,base,10)),seq(0,i=1..dgs-ndgs)]
%p A089754 end proc:
%p A089754 digcatL2 := proc(L1,L2)
%p A089754     digcatL([op(L1),op(L2)]) ;
%p A089754 end proc:
%p A089754 A089754 := proc(n)
%p A089754     local prep,a,dgs ;
%p A089754     if isprime(n) then
%p A089754         n;
%p A089754     elif modp(n,2) = 0 or modp(n,5) = 0 then
%p A089754         ndgs := convert(n,base,10) ;
%p A089754         for dgs from 1 do
%p A089754             for prep from 0 to 10^dgs-1 do
%p A089754                 a := digcatL2(ListTools[Reverse](ndgs),ListTools[Reverse](nleadzero(prep,dgs))) ;
%p A089754                 if isprime(a) then
%p A089754                     return a;
%p A089754                 end if;
%p A089754             end do:
%p A089754         end do:
%p A089754     else
%p A089754         for prep from 1 do
%p A089754             a := digcat2(prep,n) ;
%p A089754             if isprime(a) then
%p A089754                 return a;
%p A089754             end if;
%p A089754         end do:
%p A089754     end if;
%p A089754 end proc: # _R. J. Mathar_, Sep 18 2015
%Y A089754 Cf. A018800, A062584, A068164.
%K A089754 base,easy,nonn
%O A089754 1,1
%A A089754 _Amarnath Murthy_, Nov 22 2003
%E A089754 Corrected by _R. J. Mathar_, Sep 18 2015