|
|
A073901
|
|
Number of primes with nonzero digits and digit sum n.
|
|
3
|
|
|
0, 2, 1, 3, 7, 0, 29, 27, 0, 90, 234, 0, 753, 1025, 0, 3876, 9242, 0, 32549, 50112, 0, 180092, 420318, 0, 1525141, 2467286, 0, 9248093, 20668960, 0, 76318859, 130130794, 0, 487397935, 1066434006, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
a(3k) = 0 for all k>1.
The number of candidates to consider for a(n) (i.e. the number of integers with nonzero digits and digit sum n) is A104144(n+8). - Robert Israel, Jun 05 2015
|
|
LINKS
|
|
|
EXAMPLE
|
a(2) = 2: the two primes are 2 and 11. a(5) = 7: the primes are 5, 41, 23, 113, 131, 311 and 2111.
|
|
MAPLE
|
S[1, 1]:= [1]:
for x from 2 to 9 do S[1, x]:= [] od:
a[1]:= 0: a[2]:= 2:
for n from 2 to 22 do
for x from 2 to 9 do S[n, x]:= map(`+`, S[n-1, x-1], 1) od:
S[n, 1]:= [seq(op(map(t -> 10*t+1, S[n-1, x])), x=1..9)];
if n > 3 and n mod 3 = 0 then a[n]:= 0
else
if n > 5 then X:= [1, 3, 7, 9] else X:= [$1..9] fi;
a[n]:= add(numboccur(map(isprime, S[n, x]), true), x=X);
fi
od:
|
|
MATHEMATICA
|
f[n_] := If[ Mod[n, 3] == 0 && n > 3, 0, Block[{ip = IntegerPartitions@ n, lng = 1 + PartitionsP@ n, cnt = 0, k = 1}, While[k < lng, If[ Max@ ip[[k]] < 10, cnt += Length@ Select[ FromDigits@# & /@ Permutations@ ip[[k]], PrimeQ]]; k++]; cnt]]; Array[f, 30] (* Robert G. Wilson v, Jun 05 2015 *)
DigitSum[n_, b_:10] := Total[IntegerDigits[n, b]]; nextodd[c_] := If[ Length[c]==2, Join[ Table[1, {c[[1]]-2}], {c[[2]]+2}], Join[ Table[1, {c[[1]]-1}], {c[[2]]+1}, Drop[c, 2]]]; a[2]=2; a[n_] := If[Mod[n, 3]==0 && n>3, 0, Module[{c, ct}, For[ c = Table[1, {n}]; ct = 0, True, c = nextodd[c], If[ PrimeQ[ FromDigits[c]] && DigitSum[FromDigits[c]]==n, ct++ ]; If[ c[[ -1]] >= n-1, Return[ct]] ] ]]; Table[ a[n], {n, 20}]
|
|
PROG
|
(PARI) See Links section.
(Python)
from collections import Counter
from sympy.utilities.iterables import partitions, multiset_permutations
from sympy import isprime
def A073901(n): return sum(1 for p in partitions(n, k=9) for a in multiset_permutations(Counter(p).elements()) if isprime(int(''.join(str(d) for d in a)))) if n==3 or n%3 else 0 # Chai Wah Wu, Feb 21 2024
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,more,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
a(20) to a(24) and alternate Mathematica coding from Dean Hickerson, Sep 21 2002
|
|
STATUS
|
approved
|
|
|
|