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.

A345336 Prime numbers p such that the sum and the product of digits of p^2 are both squares.

Original entry on oeis.org

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
Offset: 1

Views

Author

Tanya Khovanova, Jun 14 2021

Keywords

Comments

Primes in A061868.

Examples

			101^2 = 10201. The sum of the digits is 4, the product is 0: both are squares. Thus, 101 is in the sequence.
		

Crossrefs

Cf. A061868.

Programs

  • 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:
    select(filter, [$1..10000]); # Robert Israel, Jun 17 2021
  • Mathematica
    Select[Range[3000], PrimeQ[#] && IntegerQ[Sqrt[Total[IntegerDigits[#^2]]]] && IntegerQ[Sqrt[Times @@ IntegerDigits[#^2]]] &]
    Select[Prime[Range[3500]],With[{c=IntegerDigits[#^2]},AllTrue[{Sqrt[Total[c]],Sqrt[Times@@c]},IntegerQ]]&] (* Harvey P. Dale, Feb 05 2025 *)
  • 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)
                    counter += 1; # Karl-Heinz Hofmann, Jun 17 2021