Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #26 Mar 07 2023 15:37:46
%S 2,11,67,23,89,53,83,29,173,19,197,193,337,167,269,79,757,397,379,479,
%T 3677,769,997,6967,1699,3889,9857,7867,6959,9949,16987,9887,49697,
%U 47599,18899,67979,73999,56999,197699,49999,159899,189989,98899,98999,988877
%N Least prime, p, such that p mod (sum of the digits of p) = n.
%C First occurrence of n in A136251.
%H David A. Corneth, <a href="/A138792/b138792.txt">Table of n, a(n) for n = 0..181</a> (first 74 terms from Robert G. Wilson v)
%e a(2) = 67 = 13*5+2 <--> 67 (mod 13) = 2.
%p V:= Array(0..50): count:= 0: p:= 1:
%p while count < 51 do
%p p:= nextprime(p);
%p s:= convert(convert(p,base,10),`+`);
%p v:= p mod s;
%p if v <= 50 and V[v] = 0 then V[v]:= p; count:= count+1; fi
%p od:
%p convert(V,list); # _Robert Israel_, Mar 07 2023
%t 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}]
%t 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 *)
%o (PARI) a(n) = my(p=2); while ((p % sumdigits(p)) != n, p=nextprime(p+1)); p; \\ _Michel Marcus_, Mar 07 2023
%o (Python)
%o from sympy import nextprime
%o from itertools import islice
%o def agen(): # generator of terms
%o adict, n, p = dict(), 0, 2
%o while True:
%o v = p%sum(map(int, str(p)))
%o if v not in adict: adict[v] = p
%o while n in adict: yield adict[n]; n += 1
%o p = nextprime(p)
%o print(list(islice(agen(), 45))) # _Michael S. Branicky_, Mar 07 2023
%Y Cf. A136251, A138791.
%K base,nonn
%O 0,1
%A _Robert G. Wilson v_, Mar 28 2008
%E Name corrected by _Robert Israel_, Mar 07 2023