login
Sum of composite numbers between prime p and nextprime(p) is a repdigit.
10

%I #31 Aug 14 2024 16:54:38

%S 3,5,109,111111109,259259257

%N Sum of composite numbers between prime p and nextprime(p) is a repdigit.

%C No additional terms below 472882027.

%C No additional terms below 10^58. - _Chai Wah Wu_, Jun 01 2024

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Repdigit.html">Repdigit</a>

%F Numbers A000040(n) for n > 1 such that A001043(n)*(A001223(n)-1)/2 is in A010785. - _Chai Wah Wu_, Aug 12 2014

%e a(5) is ok since between 259259257 and nextprime 259259261 we get the sum 259259258 + 259259259 + 259259260 which yield repdigit 777777777.

%t repQ[n_]:=Count[DigitCount[n],0]==9; Select[Prime[Range[2,14500000]], repQ[Total[Range[#+1,NextPrime[#]-1]]]&] (* _Harvey P. Dale_, Jan 29 2011 *)

%o (Python)

%o from sympy import prime

%o A054268 = [prime(n) for n in range(2,10**5) if len(set(str(int((prime(n+1)-prime(n)-1)*(prime(n+1)+prime(n))/2)))) == 1]

%o # _Chai Wah Wu_, Aug 12 2014

%o (Python)

%o from itertools import count, islice

%o from sympy import isprime, nextprime

%o from sympy.abc import x,y

%o from sympy.solvers.diophantine.diophantine import diop_quadratic

%o def A054268_gen(): # generator of terms

%o for l in count(1):

%o c = []

%o for m in range(1,10):

%o k = m*(10**l-1)//9<<1

%o for a, b in diop_quadratic((x-y-1)*(x+y)-k):

%o if isprime(b) and a == nextprime(b):

%o c.append(b)

%o yield from sorted(c)

%o A054268_list = list(islice(A054268_gen(),5)) # _Chai Wah Wu_, Jun 01 2024

%Y Cf. A010785, A028987, A028988, A046933, A054264, A054265, A054266, A054267.

%K nonn,base,hard

%O 1,1

%A _Patrick De Geest_, Apr 15 2000

%E Offset changed by _Andrew Howroyd_, Aug 14 2024