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.

A241018 a(n) is the smallest j such that the n-digit number consisting of a 1 in position j and 9's in the other n-1 positions is a prime, or 0 if no such prime exists.

This page as a plain text file.
%I A241018 #32 May 11 2025 18:53:44
%S A241018 1,1,1,5,1,7,1,0,2,6,3,3,11,2,14,4,0,4,6,0,4,20,6,7,18,1,1,23,8,8,23,
%T A241018 7,0,0,0,26,33,0,11,8,5,8,13,12,44,2,2,0,11,31,17,39,1,51,5,7,4,29,9,
%U A241018 16,0,0,26,14,26,10,13,0,0,34,40,0,15,3,14,32,0
%N A241018 a(n) is the smallest j such that the n-digit number consisting of a 1 in position j and 9's in the other n-1 positions is a prime, or 0 if no such prime exists.
%C A241018 Previous name: Let x(1)x(2)...x(n) denote the decimal expansion of a number p having an index j such that x(j) = 1 and x(i) = 9 for i <> j. a(n) is the smallest index j such that p is prime, or 0 if no such prime exists.
%C A241018 Except 0, the corresponding primes are 19, 199, 1999, 99991, 199999, 9999991, 19999999, 0, 9199999999, 99999199999, 991999999999, 9919999999999, ... .
%H A241018 Robert Israel, <a href="/A241018/b241018.txt">Table of n, a(n) for n = 2..4033</a>
%p A241018 with(numtheory):nn:=80:T:=array(1..nn):
%p A241018    for n from 2 to nn do:
%p A241018      for i from 1 to n do:
%p A241018      T[i]:=9:
%p A241018      od:
%p A241018        ii:=0:
%p A241018        for j from 1 to n while(ii=0)do:
%p A241018        T[j]:=1:s:=sum('T[i]*10^(n-i)', 'i'=1..n):
%p A241018          if type(s,prime)=true
%p A241018          then
%p A241018          ii:=1: printf(`%d, `,j):
%p A241018          else
%p A241018          T[j]:=9:
%p A241018          fi:
%p A241018          od:
%p A241018           if ii=0
%p A241018            then
%p A241018            printf(`%d, `,0):
%p A241018            else
%p A241018           fi:
%p A241018        od:
%t A241018 Table[With[{w = ConstantArray[9, n]}, SelectFirst[Range@ n, PrimeQ@ FromDigits@ ReplacePart[w, # -> 1] &]] /. m_ /; MissingQ@ m -> 0, {n, 2, 78}] (* _Michael De Vlieger_, Sep 13 2017 *)
%o A241018 (Python)
%o A241018 from sympy import isprime
%o A241018 def a(n):
%o A241018     base = (10**n-1)
%o A241018     for j in range(1, n+1):
%o A241018         t = base - 8*10**(n-j)
%o A241018         if isprime(t):
%o A241018             return j
%o A241018     return 0
%o A241018 print([a(n) for n in range(2, 78)]) # _Michael S. Branicky_, Jun 02 2024
%Y A241018 Cf. A241019, A241020.
%K A241018 nonn,base
%O A241018 2,4
%A A241018 _Michel Lagneau_, Apr 15 2014
%E A241018 Name simplified by _Jon E. Schoenfield_, Sep 13 2017