A106782 Primes with digit sum = 53.
989999, 1799999, 1889999, 1988999, 1989899, 1989989, 1997999, 1999799, 1999889, 1999979, 2699999, 2799899, 2799989, 2879999, 2899997, 2978999, 2979989, 2988899, 2989799, 2989997, 2998997, 2999879, 2999897, 3698999, 3789899
Offset: 1
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1..1000 from Vincenzo Librandi)
Crossrefs
Cf. similar sequences listed in A244918.
Programs
-
Magma
[p: p in PrimesUpTo(3800000) | &+Intseq(p) eq 53]; // Vincenzo Librandi, Jul 09 2014
-
Mathematica
Select[Prime[Range[270000]],Total[IntegerDigits[#]]==53&] (* Harvey P. Dale, Apr 17 2011 *)
-
PARI
select( {is_A106782(p)=sumdigits(p)==53&&isprime(p)}, primes([9e5,4e6]\1)) \\ M. F. Hasler, Mar 09 2022
-
Python
from itertools import count, islice from sympy import isprime from sympy.utilities.iterables import multiset_permutations def agen(b=10, sod=53): # 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 print(list(islice(agen(), 25))) # Michael S. Branicky, Mar 10 2022
Comments