# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a107579 Showing 1-1 of 1 %I A107579 #37 Mar 16 2022 16:39:01 %S A107579 19,37,73,109,127,163,181,271,307,433,523,541,613,631,811,1009,1063, %T A107579 1117,1153,1171,1423,1531,1621,1801,2017,2053,2143,2161,2251,2341, %U A107579 2503,2521,3061,3313,3331,3511,4051,4231,5023,5113,6121,6211,6301,8011,8101 %N A107579 Primes with digit sum 10. %C A107579 Subset of A061237 and A117674. %H A107579 Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1001..3000 from Vincenzo Librandi and Zak Seidov, terms 1..1000 from Vincenzo Librandi) %F A107579 Intersection of A000040 (primes) and A052224 (digit sum = 10). - _M. F. Hasler_, Mar 09 2022 %p A107579 a:=proc(n) local nn: nn:=convert(n,base,10): if isprime(n)=true and add(nn[j], j=1..nops(nn))=10 then n else end if end proc: seq(a(n),n=1..10^4); # _Emeric Deutsch_, Mar 06 2008 %t A107579 Select[Prime[Range[100000]], Total[IntegerDigits[#]]==10 &] (* _Vincenzo Librandi_, Jul 08 2014 *) %o A107579 (Magma) [p: p in PrimesUpTo(10000) | &+Intseq(p) eq 10]; // _Vincenzo Librandi_, Jul 08 2014 %o A107579 (PARI) forprime(p=19,8101,if(10==sumdigits(p),print(p","))) \\ _Zak Seidov_, Oct 08 2016 %o A107579 (PARI) (A107579_nxt(p)=until(isprime(p=A228915(p)),); p); A107579_first(N=100)=vector(N, i, p=if(i>1, A107579_nxt(p), 19))) \\ _M. F. Hasler_, Mar 15 2022 %o A107579 (Python) %o A107579 from itertools import count, islice %o A107579 from sympy import isprime %o A107579 from sympy.utilities.iterables import multiset_permutations %o A107579 def agen(b=10, sod=10): # generator for any base, sum-of-digits %o A107579 if 0 <= sod < b: %o A107579 yield sod %o A107579 nzdigs = [i for i in range(1, b) if i <= sod] %o A107579 nzmultiset = [] %o A107579 for d in range(1, b): %o A107579 nzmultiset += [d]*(sod//d) %o A107579 for d in count(2): %o A107579 fullmultiset = [0]*(d-1-(sod-1)//(b-1)) + nzmultiset %o A107579 for firstdig in nzdigs: %o A107579 target_sum, restmultiset = sod - int(firstdig), fullmultiset[:] %o A107579 restmultiset.remove(firstdig) %o A107579 for p in multiset_permutations(restmultiset, d-1): %o A107579 if sum(p) == target_sum: %o A107579 t = int("".join(map(str, [firstdig]+p)), b) %o A107579 if isprime(t): %o A107579 yield t %o A107579 if p[0] == target_sum: %o A107579 break %o A107579 print(list(islice(agen(), 45))) # _Michael S. Branicky_, Mar 10 2022 %o A107579 (Python) %o A107579 from sympy import isprime %o A107579 def A107579(p=19): %o A107579 "Return a generator of the sequence of all primes >= p with the same digit sum as p." %o A107579 while True: %o A107579 if isprime(p): yield p %o A107579 p = A228915(p) # skip to next larger integer with the same digit sum %o A107579 a=A107579(); [next(a) for _ in range(50)] # _M. F. Hasler_, Mar 16 2022 %Y A107579 Cf. A000040 (primes), A007953 (sum of digits), A052224 (digit sum = 10). %Y A107579 Cf. A061237 (sum of digits == 1 (mod 9)). %Y A107579 Subsequence of A062340 (primes with digit sum divisible by 5). %Y A107579 Cf. A062339 (same for digit sum s = 4), A062341 (s = 5), A062343 (s = 8), A106754 (s = 11), and others listed in A244918 (s = 68). %K A107579 nonn,base %O A107579 1,1 %A A107579 _Zak Seidov_, May 16 2005 %E A107579 Edited by _N. J. A. Sloane_, Feb 20 2009 at the suggestion of Pacha Nambi # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE