A082257 Duplicate of A054750.
2, 3, 5, 7, 29, 67, 89, 199, 599, 2999, 4999, 29989, 59999, 79999, 389999, 989999
Offset: 1
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.
a(68) = 59999999 because 59999999 is the smallest prime with digit sum = 68; a(100) = 298999999999 because 298999999999 is the smallest prime with digit sum = 100.
g:= proc(s,d) # integers of <=d digits with sum s if s > 9*d then return [] fi; if d = 1 then return [s] fi; [seq(op(map(t -> j*10^(d-1)+ t, g(s-j,d-1))),j=0..9)]; end proc: f:= proc(n) local d, j,x,y; if n mod 3 = 0 then return 0 fi; for d from ceil(n/9) do if d = 1 then if isprime(n) and n < 10 then return n else next fi fi; for j from 1 to 9 do for y in g(n-j,d-1) do x:= 10^(d-1)*j + y; if isprime(x) then return x fi; od od od; end proc: f(1):= 0: f(3):= 3: map(f, [$1..100]); # Robert Israel, Dec 13 2020
a = Table[0, {100}]; Do[b = Apply[ Plus, IntegerDigits[ Prime[n]]]; If[b < 101 && a[[b]] == 0, a[[b]] = Prime[n]], {n, 1, 10^7} ]; a f[n_] := If[n > 5 && Mod[n, 3] == 0, 0, Block[{k = 1, lmt, lst = {}, ip = IntegerPartitions[n, Round[1 + n/9], {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}]}, lmt = 1 + Length@ ip; While[k < lmt, AppendTo[lst, Select[ FromDigits@# & /@ Permutations@ ip[[k]], PrimeQ[#] &]]; k++]; Min@ Flatten@ lst]]; f[1] = 0; f[4] = 13; Array[f, 70] (* Robert G. Wilson v, Sep 28 2014 *)
A067180(n)={if(n<2, 0, n<4, n, n%3, my(d=divrem(n,9)); forprime(p=d[2]*10^d[1]-1,,sumdigits(p)==n&&return(p)))} \\ M. F. Hasler, Nov 04 2018
from _future_ import division from itertools import combinations from sympy import prime, isprime def A157712(n): if n == 1: return 11 if n == 2: return 0 p = prime(n) l = p while True: for i in combinations(range(l),l-p): s = ['1']*l for x in i: s[x] = '0' q = int(''.join(s)) if isprime(q): return q l += 1 # Chai Wah Wu, Nov 05 2015
The first composite is 4, and the first sum of digits is 13, but since that is prime, we go to the next, 22, which being composite is a(1).
A161551 := proc(n) for j from n+1 do if digsum(A002808(j)) = A002808(n) then return A002808(j) ; end if; end do: end proc: seq(A161551(n),n=1..30) ; # R. J. Mathar, Dec 06 2011
10 'compsdig, Enoch Haga, Jun 12 2009 20 N=1 30 Q=str(N) 40 L=len(Q) 50 for X=1 to L 60 M=str(mid(Q,X,1)): Z=Z+val(mid(Q,X,1)) 70 next X 80 if Z=56 and Z<>prmdiv(Z) and N<>prmdiv(N) then print N: stop 90 Z=0: N=N+1: goto 30
The 125th prime is 691. The least integer with sum of digits 691 is A051885(691) = 8*10^76-1 which is prime. This is the 22nd prime with this property, so a(22)=125.
for(X=1,300, a=prime(X)%9; b=prime(X)\9; m=(a+1)*10^b-1; if(isprime(m), print([X,prime(X),m]) ) )
a[n_]:=10^(Floor[2^n/9])(1+2^n-9Floor[2^n/9])-1; Array[a,11,0]
def A382461(n): return (lambda x:(x[1]+1)*10**x[0]-1)(divmod(1<Chai Wah Wu, Mar 29 2025
a(4)=13 because the sums of digits of the candidates 5 to 12 are all different from n=4, and 13 is the first candidate with sum 1+3 = n = 4.
dsn[n_]:=Module[{k=n+1},While[Total[IntegerDigits[k]]!=n,k++];k]; Array[ dsn,50] (* Harvey P. Dale, Oct 24 2020 *)
a(n) = my(m = n+1); while(sumdigits(m) != n, m++); m; \\ Michel Marcus, Jun 08 2014
a(10) = 430 because prime(430) = 2999, 2 + 9 + 9 + 9 = 29 = prime(10) and this is the smallest such number.
Module[{nn=522*10^4,tbl},tbl=Table[{n,Total[IntegerDigits[Prime[n]]]},{n,nn}];Table[SelectFirst[tbl,#[[2]]==Prime[n]&],{n,20}]][[;;,1]] (* The program generates the first 20 terms of the sequence. *) (* Harvey P. Dale, Feb 19 2023 *)
Comments