login
Numbers with digits in nondecreasing order whose digit sum is prime and whose digit product is a perfect square > 0.
1

%I #23 Jun 18 2021 18:46:11

%S 11,14,49,111,119,122,128,133,155,166,188,199,229,236,289,368,449,559,

%T 779,1114,1334,1444,1466,1477,1499,2249,2489,3349,4559,4889,4999,

%U 11111,11119,11122,11128,11144,11155,11177,11188,11236,11339,11368,11449,11669,11999,12233

%N Numbers with digits in nondecreasing order whose digit sum is prime and whose digit product is a perfect square > 0.

%C Primitive sequence of A344825.

%H David A. Corneth, <a href="/A344842/b344842.txt">Table of n, a(n) for n = 1..29793</a> (terms <= 10^15)

%e 49 is in the sequence as its product of digits is 36 which is a perfect square > 0 and its sum of digits is 13 which is prime.

%t ndoQ[n_]:=Module[{id=IntegerDigits[n]},FreeQ[id,0]&&Min[ Differences[id]]> = 0&&PrimeQ[Total[id]]&&IntegerQ[Sqrt[Times@@id]]]; Select[Range[ 12500],ndoQ] (* _Harvey P. Dale_, Jun 18 2021 *)

%o (Python)

%o from math import prod

%o from sympy import isprime, integer_nthroot

%o from itertools import combinations_with_replacement as mc

%o def ok(s):

%o d = list(map(int, s))

%o return '0' not in s and isprime(sum(d)) and integer_nthroot(prod(d), 2)[1]

%o def auptod(digits): return [int("".join(p)) for d in range(2, digits+1) for p in mc("123456789", d) if ok("".join(p))]

%o print(auptod(5)) # _Michael S. Branicky_, May 29 2021

%o (PARI) uptoqdigits(n) = { my(res = List()); for(j = 2, n, forvec(x = vector(j, i, [1,9]), if(issquare(vecprod(x)) && isprime(vecsum(x)), listput(res, fromdigits(x)) ) , 1 ) ); res }

%Y Cf. A009994, A344825.

%K nonn,base

%O 1,1

%A _David A. Corneth_, May 29 2021

%E Definition (Name) corrected by _Harvey P. Dale_, Jun 18 2021