|
|
A107579
|
|
Primes with digit sum 10.
|
|
13
|
|
|
19, 37, 73, 109, 127, 163, 181, 271, 307, 433, 523, 541, 613, 631, 811, 1009, 1063, 1117, 1153, 1171, 1423, 1531, 1621, 1801, 2017, 2053, 2143, 2161, 2251, 2341, 2503, 2521, 3061, 3313, 3331, 3511, 4051, 4231, 5023, 5113, 6121, 6211, 6301, 8011, 8101
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
FORMULA
|
|
|
MAPLE
|
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
|
|
MATHEMATICA
|
Select[Prime[Range[100000]], Total[IntegerDigits[#]]==10 &] (* Vincenzo Librandi, Jul 08 2014 *)
|
|
PROG
|
(Magma) [p: p in PrimesUpTo(10000) | &+Intseq(p) eq 10]; // Vincenzo Librandi, Jul 08 2014
(PARI) forprime(p=19, 8101, if(10==sumdigits(p), print(p", "))) \\ Zak Seidov, Oct 08 2016
(Python)
from itertools import count, islice
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations
def agen(b=10, sod=10): # generator for any base, sum-of-digits
if 0 <= sod < b:
yield sod
nzdigs = [i for i in range(1, b) if i <= sod]
nzmultiset = []
for d in range(1, b):
nzmultiset += [d]*(sod//d)
for d in count(2):
fullmultiset = [0]*(d-1-(sod-1)//(b-1)) + nzmultiset
for firstdig in nzdigs:
target_sum, restmultiset = sod - int(firstdig), fullmultiset[:]
restmultiset.remove(firstdig)
for p in multiset_permutations(restmultiset, d-1):
if sum(p) == target_sum:
t = int("".join(map(str, [firstdig]+p)), b)
if isprime(t):
yield t
if p[0] == target_sum:
break
(Python)
from sympy import isprime
"Return a generator of the sequence of all primes >= p with the same digit sum as p."
while True:
if isprime(p): yield p
p = A228915(p) # skip to next larger integer with the same digit sum
|
|
CROSSREFS
|
Cf. A061237 (sum of digits == 1 (mod 9)).
Subsequence of A062340 (primes with digit sum divisible by 5).
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|