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:
seq(a[n], n=1..22); # Robert Israel, Jun 05 2015
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
Amarnath Murthy, Aug 18 2002
EXTENSIONS
Edited and extended by Robert G. Wilson v, Sep 19 2002
a(20) to a(24) and alternate Mathematica coding from Dean Hickerson, Sep 21 2002
a(25) from Robert G. Wilson v, Sep 26 2002
a(26)-a(31) from Robert G. Wilson v, Nov 14 2005
Corrected and edited by Manfred Scheucher, Jun 01 2015
a(32)-a(33) from Rémy Sigrist, Nov 17 2022
a(34)-a(36) from Michael S. Branicky, Jul 03 2023
STATUS
approved