cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A308917 Primes p such that the digits of p^2 are squares.

Original entry on oeis.org

2, 3, 7, 97, 107, 701, 997, 1049, 7001, 10007, 10243, 20347, 70001, 97001, 100549, 202757, 306749, 379499, 700001, 997001, 1002247, 1070021, 3317257, 3346507, 9536249, 9970001, 10095247, 20470501, 21095021, 22144979, 94925771, 100000007, 100099501, 104933743, 202520347
Offset: 1

Views

Author

Bernard Schott, Jun 30 2019

Keywords

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)

Examples

			997 is a term because 997 is prime and 997^2 = 994009 with 0, 4, 9 that are all squares.
		

Crossrefs

Cf. subsequences: A159031, A316969.
Intersection of A000040 and A285550.

Programs

  • 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
    
  • 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 *)
  • PARI
    isok(p) = isprime(p) && (d=digits(p^2)) && (#select(x->issquare(x), d) == #d); \\ Michel Marcus, Jun 30 2019

Extensions

More terms from Michel Marcus, Jun 30 2019