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.

A138792 Least prime, p, such that p mod (sum of the digits of p) = n.

Original entry on oeis.org

2, 11, 67, 23, 89, 53, 83, 29, 173, 19, 197, 193, 337, 167, 269, 79, 757, 397, 379, 479, 3677, 769, 997, 6967, 1699, 3889, 9857, 7867, 6959, 9949, 16987, 9887, 49697, 47599, 18899, 67979, 73999, 56999, 197699, 49999, 159899, 189989, 98899, 98999, 988877
Offset: 0

Views

Author

Robert G. Wilson v, Mar 28 2008

Keywords

Comments

First occurrence of n in A136251.

Examples

			a(2) = 67 = 13*5+2 <--> 67 (mod 13) = 2.
		

Crossrefs

Programs

  • Maple
    V:= Array(0..50): count:= 0: p:= 1:
    while count < 51 do
      p:= nextprime(p);
      s:= convert(convert(p,base,10),`+`);
      v:= p mod s;
      if v <= 50 and V[v] = 0 then V[v]:= p; count:= count+1;  fi
    od:
    convert(V,list); # Robert Israel, Mar 07 2023
  • Mathematica
    f[n_] := Block[{p = Prime@ n}, Mod[p, Plus @@ IntegerDigits@ p]]; t = Table[0, {1000}]; Do[ a = f@n; If[a < 1000 && t[[a + 1]] == 0, t[[a + 1]] = Prime@ n; Print[{a, Prime@n}]], {n, 503200000}]
    lp[n_]:=Module[{p=2},While[Mod[p,Total[IntegerDigits[p]]]!=n,p= NextPrime[ p]];p]; Array[lp,50,0] (* Harvey P. Dale, Jan 15 2019 *)
  • PARI
    a(n) = my(p=2); while ((p % sumdigits(p)) != n, p=nextprime(p+1)); p; \\ Michel Marcus, Mar 07 2023
    
  • Python
    from sympy import nextprime
    from itertools import islice
    def agen(): # generator of terms
        adict, n, p = dict(), 0, 2
        while True:
            v = p%sum(map(int, str(p)))
            if v not in adict: adict[v] = p
            while n in adict: yield adict[n]; n += 1
            p = nextprime(p)
    print(list(islice(agen(), 45))) # Michael S. Branicky, Mar 07 2023

Extensions

Name corrected by Robert Israel, Mar 07 2023