The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A047814 Largest prime substring of n, or 0 if no such substring exists. 6

%I #22 Dec 29 2023 23:18:34

%S 0,0,2,3,0,5,0,7,0,0,0,11,2,13,0,5,0,17,0,19,2,2,2,23,2,5,2,7,2,29,3,

%T 31,3,3,3,5,3,37,3,3,0,41,2,43,0,5,0,47,0,0,5,5,5,53,5,5,5,7,5,59,0,

%U 61,2,3,0,5,0,67,0,0,7,71,7,73,7,7,7,7,7,79,0,0,2,83,0,5,0,7,0,89

%N Largest prime substring of n, or 0 if no such substring exists.

%C A211396(n) <= a(n). - _Reinhard Zumkeller_, Feb 08 2013

%H Reinhard Zumkeller, <a href="/A047814/b047814.txt">Table of n, a(n) for n = 0..10000</a>

%e a(10)=0, a(1227)=227.

%t a[n_] := (id = IntegerDigits[n]; lg = Length[id]; sel = Select[ FromDigits /@ Flatten[ Table[ id[[i ;; j]], {i, 1, lg}, {j, i, lg}], 1], PrimeQ]; If[ sel === {}, 0, Last[ Sort[ sel] ] ]); Table[ a[n], {n, 0, 99}] (* _Jean-François Alcover_, Feb 23 2012 *)

%t lps[m_]:=Max[Select[Flatten[Table[FromDigits/@Partition[ IntegerDigits[ m],n,1],{n,IntegerLength[m]}]],PrimeQ]]; Array[lps,100,0]/. -\[Infinity]->0 (* _Harvey P. Dale_, Feb 26 2014 *)

%o (Haskell)

%o import Data.List (isInfixOf)

%o a047814 n = if null ips then 0 else head ips

%o where ips = [p | p <- reverse $ takeWhile (<= n) a000040_list,

%o show p `isInfixOf` show n]

%o -- _Reinhard Zumkeller_, Feb 08 2013

%Y Cf. A211396.

%K nonn,easy,base,nice,look

%O 0,3

%A _N. J. A. Sloane_

%E Corrected (41) by _Jean-François Alcover_, Feb 23 2012

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 May 25 15:05 EDT 2024. Contains 372791 sequences. (Running on oeis4.)