cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A062341 Primes whose sum of digits is 5.

Original entry on oeis.org

5, 23, 41, 113, 131, 311, 401, 1013, 1031, 1103, 1301, 2003, 2111, 3011, 4001, 10103, 10211, 10301, 11003, 12011, 12101, 13001, 20021, 20201, 21011, 21101, 30011, 100103, 101021, 101111, 102101, 103001, 120011, 121001, 200003, 200201, 201011, 201101, 202001
Offset: 1

Views

Author

Amarnath Murthy, Jun 21 2001

Keywords

Examples

			1301 belongs to the sequence since it is a prime with sum of digits = 5.
		

Crossrefs

Cf. A000040 (primes), A007953 (sum of digits), A052219 (digit sum = 5).
Cf. A062339 (same for digit sum s = 4), A062337 (s = 7), and others listed in A244918 (s = 68).
Subsequence of A062340 (primes with sum of digits divisible by 5).

Programs

  • Magma
    [p: p in PrimesUpTo(250000) | &+Intseq(p) eq 5]; // Vincenzo Librandi, Jul 08 2014
    
  • Maple
    T:= n-> `if`(n=1, 5, sort(select(isprime, [seq(seq(seq(
        10^(n-1)+1+10^i+10^j+10^k, k=1..j), j=1..i), i=1..n-1),
        seq(10^(n-1)+3+10^i, i=1..n-1)]))[]):
    seq(T(n), n=1..8);  # Alois P. Heinz, Dec 28 2015
  • Mathematica
    Select[Prime[Range[20000]],Total[IntegerDigits[#]]==5&] (* Harvey P. Dale, Nov 24 2013 *)
  • PARI
    \\ From M. F. Hasler, Mar 09 2022: (Start)
    select( {is_A062341(p,s=5)=sumdigits(p)==s&&isprime(p)}, primes([1,10^6])) \\ 2nd optional parameter for similar sequences with other digit sums.
    A062341_upto_length(L,s=5,a=List(),u=[10^k|k<-[0..L-1]])={forvec(d=[[1,L]|i<-[1..s]], isprime(p=vecsum(vecextract(u,d))) && listput(a,p),1); Set(a)} \\ (End)
  • Python
    from sympy import primerange as primes
    def ok(p): return sum(map(int, str(p))) == 5
    print(list(filter(ok, primes(1, 202002)))) # Michael S. Branicky, May 23 2021
    

Formula

Intersection of A000040 (primes) with A052219 (digit sum 5). - M. F. Hasler, Mar 09 2022

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jul 06 2001

A107579 Primes with digit sum 10.

Original entry on oeis.org

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
Offset: 1

Views

Author

Zak Seidov, May 16 2005

Keywords

Comments

Subset of A061237 and A117674.

Crossrefs

Cf. A000040 (primes), A007953 (sum of digits), A052224 (digit sum = 10).
Cf. A061237 (sum of digits == 1 (mod 9)).
Subsequence of A062340 (primes with digit sum divisible by 5).
Cf. A062339 (same for digit sum s = 4), A062341 (s = 5), A062343 (s = 8), A106754 (s = 11), and others listed in A244918 (s = 68).

Programs

  • Magma
    [p: p in PrimesUpTo(10000) | &+Intseq(p) eq 10]; // Vincenzo Librandi, Jul 08 2014
    
  • 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 *)
  • PARI
    forprime(p=19,8101,if(10==sumdigits(p),print(p","))) \\ Zak Seidov, Oct 08 2016
    
  • 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
    
  • 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
    print(list(islice(agen(), 45))) # Michael S. Branicky, Mar 10 2022
    
  • Python
    from sympy import isprime
    def A107579(p=19):
        "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
    a=A107579(); [next(a) for  in range(50)] # _M. F. Hasler, Mar 16 2022

Formula

Intersection of A000040 (primes) and A052224 (digit sum = 10). - M. F. Hasler, Mar 09 2022

Extensions

Edited by N. J. A. Sloane, Feb 20 2009 at the suggestion of Pacha Nambi
Showing 1-2 of 2 results.