login
Primes p such that digits of p appear in p^2.
2

%I #16 Dec 23 2017 17:43:12

%S 5,11,101,139,199,211,277,421,463,499,503,509,523,593,601,631,661,733,

%T 757,887,911,991,1021,1091,1117,1163,1171,1193,1201,1277,1319,1451,

%U 1523,1601,1621,1627,1777,1783,1999,2011,2027,2111,2161,2203

%N Primes p such that digits of p appear in p^2.

%H Reinhard Zumkeller, <a href="/A030079/b030079.txt">Table of n, a(n) for n = 1..10000</a>

%t ok[p_] := (idp = Union[ IntegerDigits[p]]; Intersection[idp, Union[ IntegerDigits[p^2]]] == idp); Select[ Prime[Range[400]], ok] (* _Jean-François Alcover_, Nov 30 2011 *)

%t Select[Prime[Range[400]],SubsetQ[IntegerDigits[#^2],IntegerDigits[#]]&] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Dec 23 2017 *)

%o (Haskell)

%o import Data.List (intersect, nub)

%o a030079 n = a030079_list !! (n-1)

%o a030079_list = filter f a000040_list where

%o f p = pd == pd `intersect` (nub $ show (p^2)) where

%o pd = nub $ show p

%o -- _Reinhard Zumkeller_, Nov 03 2011

%K nonn,base,nice

%O 1,1

%A _Patrick De Geest_