login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A073901 Number of primes with nonzero digits and digit sum n. 3

%I #52 Feb 21 2024 12:17:51

%S 0,2,1,3,7,0,29,27,0,90,234,0,753,1025,0,3876,9242,0,32549,50112,0,

%T 180092,420318,0,1525141,2467286,0,9248093,20668960,0,76318859,

%U 130130794,0,487397935,1066434006,0

%N Number of primes with nonzero digits and digit sum n.

%C a(3k) = 0 for all k>1.

%C 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

%H Manfred Scheucher, <a href="/A073901/a073901.sage.txt">Sage Script</a>

%H Rémy Sigrist, <a href="/A073901/a073901.gp.txt">PARI program</a>

%e a(2) = 2: the two primes are 2 and 11. a(5) = 7: the primes are 5, 41, 23, 113, 131, 311 and 2111.

%p S[1,1]:= [1]:

%p for x from 2 to 9 do S[1,x]:= [] od:

%p a[1]:= 0: a[2]:= 2:

%p for n from 2 to 22 do

%p for x from 2 to 9 do S[n,x]:= map(`+`,S[n-1,x-1],1) od:

%p S[n,1]:= [seq(op(map(t -> 10*t+1, S[n-1,x])),x=1..9)];

%p if n > 3 and n mod 3 = 0 then a[n]:= 0

%p else

%p if n > 5 then X:= [1,3,7,9] else X:= [$1..9] fi;

%p a[n]:= add(numboccur(map(isprime,S[n,x]),true),x=X);

%p fi

%p od:

%p seq(a[n],n=1..22); # _Robert Israel_, Jun 05 2015

%t 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 *)

%t 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}]

%o (PARI) See Links section.

%o (Python)

%o from collections import Counter

%o from sympy.utilities.iterables import partitions, multiset_permutations

%o from sympy import isprime

%o 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

%Y Not the same as A116381.

%Y Cf. A104144.

%K base,more,nonn

%O 1,2

%A _Amarnath Murthy_, Aug 18 2002

%E Edited and extended by _Robert G. Wilson v_, Sep 19 2002

%E a(20) to a(24) and alternate Mathematica coding from _Dean Hickerson_, Sep 21 2002

%E a(25) from _Robert G. Wilson v_, Sep 26 2002

%E a(26)-a(31) from _Robert G. Wilson v_, Nov 14 2005

%E Corrected and edited by _Manfred Scheucher_, Jun 01 2015

%E a(32)-a(33) from _Rémy Sigrist_, Nov 17 2022

%E a(34)-a(36) from _Michael S. Branicky_, Jul 03 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 28 03:36 EDT 2024. Contains 375477 sequences. (Running on oeis4.)