|
|
A345336
|
|
Prime numbers p such that the sum and the product of digits of p^2 are both squares.
|
|
1
|
|
|
2, 3, 101, 103, 257, 283, 347, 401, 463, 491, 499, 509, 571, 599, 653, 661, 743, 751, 797, 1013, 1021, 1031, 1039, 1103, 1201, 1229, 1237, 1301, 1381, 1399, 1427, 1453, 1499, 1553, 1571, 1597, 1667, 1733, 1741, 1759, 1823, 2003, 2011
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
EXAMPLE
|
101^2 = 10201. The sum of the digits is 4, the product is 0: both are squares. Thus, 101 is in the sequence.
|
|
MAPLE
|
filter:= proc(n) local L;
if not isprime(n) then return false fi;
L:= convert(n^2, base, 10);
issqr(convert(L, `+`)) and issqr(convert(L, `*`))
end proc:
|
|
MATHEMATICA
|
Select[Range[3000], PrimeQ[#] && IntegerQ[Sqrt[Total[IntegerDigits[#^2]]]] && IntegerQ[Sqrt[Times @@ IntegerDigits[#^2]]] &]
|
|
PROG
|
(PARI) isok(p) =if (isprime(p), my(d=digits(p^2)); issquare(vecsum(d)) && issquare(vecprod(d))); \\ Michel Marcus, Jun 14 2021
(Python) from numbthy import isprime
counter = 1
for p in range (2, 1090821):
if isprime(p) and (counter <= 10000):
pp_product = 1
pp_sum = 0
for digit in range (0, len(str(p*p))):
pp_product *= int(str(p*p)[digit])
pp_sum += int(str(p*p)[digit])
if pow(int(pp_product**0.5), 2) == pp_product:
if pow(int(pp_sum**0.5), 2) == pp_sum:
print(counter, p)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|