OFFSET
1,1
COMMENTS
The prime numbers of the form p = 7 * 10^k + 1 with k > = 2 are terms of the sequence. For example, for k = 2, 3, 4, 5, 8, 9, 45, 136, 142, 158, 243, 923, .... The squares have the form p^2 = 49 * 10^(2*k) + 14 * 10^k + 1 and the digits 0, 1, 4 and 9. - Marius A. Burtea, Jul 01 2019
Same remark with primes of the form p = 10^k + 7 and k > = 2 that are also terms of this sequence. For example, for k = 2, 4, 8, 9, ... The squares have the form p^2 = 100^k + 14 * 10^k + 49, so with only the digits 0, 1, 4 and 9. These primes are in A159031 \ {17}. - Bernard Schott, Jul 01 2019
From Chai Wah Wu, Jul 03 2019: (Start)
The prime numbers of the form p = (10^m-3)*10^k + 1 with k > m > 0 are terms of this sequence. Note that this includes primes of the form 7 * 10^k + 1 with k >=2 described in the first comment above. The squares are of the form p^2 = (10^m-3)^2*10^(2*k) + 2(10^m-3)*10^k + 1. Note that (10^m-3)^2 = 10^m(10^m-6)+9 which only contains the digits 0, 4 and 9. Similarly, 2*(10^m-3) = 2*10^m-6 which only contains the digits 1, 9 and 4 and has m+1 <= k decimal digits. Thus p^2 only contains the digits 0, 1, 4, 9. Some examples include (m,k) = (2,3), (2,8), (2,15), (3,4), (3,18), (4,71), (5,20), (6,7), ...
A similar argument shows that prime numbers of the form p = 10^k + (10^m-3) for k >= 2*m > 0 (which includes the primes of the form 10^k+7) are also terms of this sequence. In this case some examples include (m,k) = (2,9), (2,10), (3,12), (3,18), (4,10), (4,11), (5,14), ...
Some other sets of terms are:
1. primes of the form p = 20247*10^k+1 for k >= 5. Examples include k = 7, 25, 29, 31, ...
2. primes of the form p = 10^k + 20247 for k >= 9. Examples include k = 11, 15, 18, 19, 20, ...
3. primes of the form p = 2224745247*10^k+1 for k >= 10. Examples include k = 31, 57, 115, 163, ...
4. primes of the form p = 10^k + 2224745247 for k >= 19. Examples include k = 87, 257, 645, 819, ...
(End)
LINKS
Giovanni Resta, Table of n, a(n) for n = 1..512
G. L. Honaker, Jr. and Chris Caldwell, Prime Curios!, 446653271.
EXAMPLE
997 is a term because 997 is prime and 997^2 = 994009 with 0, 4, 9 that are all squares.
MATHEMATICA
ok[n_] := AllTrue[IntegerDigits[n], MemberQ[{0, 1, 4, 9}, #] &]; mo = Select[Range[1, 10^6, 2], ok@Mod[#^2, 10^6] &]; Reap[Sow@2; Do[x = 10^6 t + m; If[PrimeQ[x] && ok[x^2], Sow[x]], {t, 0, 202}, {m, mo}]][[2, 1]] (* Giovanni Resta, Jul 02 2019 *)
Select[Prime[Range[11211000]], AllTrue[Sqrt[IntegerDigits[#^2]], IntegerQ]&] (* Harvey P. Dale, Aug 17 2021 *)
PROG
(MATLAB) p=primes(10000000); m=1;
for u=1:length(p) digit=dec2base(p(u).^2, 10)-'0';
if (mod(sqrt(digit), 1) == 0) sol(m)=p(u); m=m+1; end
end
sol % Marius A. Burtea, Jun 30 2019
(PARI) isok(p) = isprime(p) && (d=digits(p^2)) && (#select(x->issquare(x), d) == #d); \\ Michel Marcus, Jun 30 2019
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Jun 30 2019
EXTENSIONS
More terms from Michel Marcus, Jun 30 2019
STATUS
approved