%I #31 Feb 05 2025 18:31:56
%S 2,3,101,103,257,283,347,401,463,491,499,509,571,599,653,661,743,751,
%T 797,1013,1021,1031,1039,1103,1201,1229,1237,1301,1381,1399,1427,1453,
%U 1499,1553,1571,1597,1667,1733,1741,1759,1823,2003,2011
%N Prime numbers p such that the sum and the product of digits of p^2 are both squares.
%C Primes in A061868.
%H Karl-Heinz Hofmann, <a href="/A345336/b345336.txt">Table of n, a(n) for n = 1..10000</a>
%e 101^2 = 10201. The sum of the digits is 4, the product is 0: both are squares. Thus, 101 is in the sequence.
%p filter:= proc(n) local L;
%p if not isprime(n) then return false fi;
%p L:= convert(n^2,base,10);
%p issqr(convert(L,`+`)) and issqr(convert(L,`*`))
%p end proc:
%p select(filter, [$1..10000]); # _Robert Israel_, Jun 17 2021
%t Select[Range[3000], PrimeQ[#] && IntegerQ[Sqrt[Total[IntegerDigits[#^2]]]] && IntegerQ[Sqrt[Times @@ IntegerDigits[#^2]]] &]
%t Select[Prime[Range[3500]],With[{c=IntegerDigits[#^2]},AllTrue[{Sqrt[Total[c]],Sqrt[Times@@c]},IntegerQ]]&] (* _Harvey P. Dale_, Feb 05 2025 *)
%o (PARI) isok(p) =if (isprime(p), my(d=digits(p^2)); issquare(vecsum(d)) && issquare(vecprod(d))); \\ _Michel Marcus_, Jun 14 2021
%o (Python) from numbthy import isprime
%o counter = 1
%o for p in range (2,1090821):
%o if isprime(p) and (counter <= 10000):
%o pp_product = 1
%o pp_sum = 0
%o for digit in range (0, len(str(p*p))):
%o pp_product *= int(str(p*p)[digit])
%o pp_sum += int(str(p*p)[digit])
%o if pow(int(pp_product**0.5),2) == pp_product:
%o if pow(int(pp_sum**0.5),2) == pp_sum:
%o print(counter, p)
%o counter += 1; # _Karl-Heinz Hofmann_, Jun 17 2021
%Y Cf. A061868.
%K nonn,base
%O 1,1
%A _Tanya Khovanova_, Jun 14 2021