login
Primes p such that the decimal digits of p^2 can be partitioned into two or more nonzero squares.
5

%I #17 Jul 10 2021 10:49:34

%S 7,13,19,37,41,107,191,223,379,487,997,1063,1093,1201,1301,1907,2029,

%T 3019,3169,3371,5081,5099,5693,6037,9041,9619,9721,9907,10007,11681,

%U 12227,12763,17393,18493,19013,19213,19219,21059,21157,21193,25931

%N Primes p such that the decimal digits of p^2 can be partitioned into two or more nonzero squares.

%H Reinhard Zumkeller, <a href="/A048646/b048646.txt">Table of n, a(n) for n = 1..1000</a>

%e 7 is present because 7^2=49 can be partitioned into two squares 4 and 9; 13^2 = 169 = 16_9; 37^2 = 1369 = 1_36_9.

%e 997^2 = 994009 = 9_9_400_9, 1063^2 = 1129969 = 1_12996_9, 997 and 1063 are primes, so 997 and 1063 are in the sequence.

%o (Haskell)

%o a048646 n = a048646_list !! (n-1)

%o a048646_list = filter ((== 1) . a010051') a048653_list

%o -- _Reinhard Zumkeller_, Apr 17 2015

%o (Python)

%o from math import isqrt

%o from sympy import primerange

%o def issquare(n): return isqrt(n)**2 == n

%o def ok(n, c):

%o if n%10 in {2, 3, 7, 8}: return False

%o if issquare(n) and c > 1: return True

%o d = str(n)

%o for i in range(1, len(d)):

%o if d[i] != '0' and issquare(int(d[:i])) and ok(int(d[i:]), c+1):

%o return True

%o return False

%o def aupto(lim): return [p for p in primerange(1, lim+1) if ok(p*p, 1)]

%o print(aupto(25931)) # _Michael S. Branicky_, Jul 10 2021

%Y Cf. A048375.

%Y Cf. A010051, intersection of A048653 and A000040.

%K nice,nonn,base

%O 1,1

%A _Felice Russo_

%E Corrected and extended by _Naohiro Nomoto_, Sep 01 2001

%E "Nonzero" added to definition by _N. J. A. Sloane_, May 08 2021