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.

A371895 a(n) is the least k>0 such that n*k contains the n-th prime as a substring.

This page as a plain text file.
%I A371895 #19 Jun 07 2024 14:09:23
%S A371895 2,15,5,18,22,22,25,24,26,29,21,31,32,31,98,96,27,34,88,355,13,36,21,
%T A371895 79,39,39,189,383,376,371,41,41,416,41,426,42,425,43,43,433,419,431,
%U A371895 237,44,266,433,45,465,464,458,83,46,423,417,468,47,472,468,47,469,103,473,488,486,202,481,348,496,63,499
%N A371895 a(n) is the least k>0 such that n*k contains the n-th prime as a substring.
%C A371895 From _Robert Israel_, Jun 06 2024: (Start)
%C A371895 If n is divisible by 2*10^k or 5*10^k, a(n) >= prime(n)*10^(k+1)/n.
%C A371895 Let n = 2^b * 5^c * k with k coprime to 10, and suppose prime(n) has d digits. If b <= c, then f(n) < 10^d * 2^(c-b).  If b > c, then f(n) < 10^d * 5^(b-c).
%C A371895 a(10^k) = prime(10^k).
%C A371895 a(2*10^k) = 5 * prime(2*10^k).
%C A371895 a(5*10^k) = 2 * prime(5*10^k). (End)
%H A371895 Robert Israel, <a href="/A371895/b371895.txt">Table of n, a(n) for n = 1..10000</a>
%e A371895 a(8) = 24 because 24 is the least positive integer such that 24*8 = 192 contains the prime(8) = 19.
%p A371895 f:= proc(n) local t,k;
%p A371895   t:= convert(ithprime(n),string);
%p A371895   for k from 1 do
%p A371895      if StringTools:-Search(t, convert(n*k,string)) > 0 then return k fi
%p A371895   od
%p A371895 end proc:
%p A371895 map(f, [$1..100]); # _Robert Israel_, Jun 05 2024
%t A371895 a[n_]:=(k=1;While[!StringContainsQ[ToString[n*k],ToString@Prime@n],k++];k); Array[a,70]
%o A371895 (Python)
%o A371895 from sympy import prime
%o A371895 from itertools import count
%o A371895 def a(n): t=str(prime(n)); return next(k for k in count(1) if t in str(n*k))
%o A371895 print([a(n) for n in range(1, 71)]) # _Michael S. Branicky_, Apr 11 2024
%o A371895 (Python) # faster for initial segment of sequence
%o A371895 from sympy import nextprime
%o A371895 from itertools import count, islice
%o A371895 def agen(): # generator of terms
%o A371895     pn = 2
%o A371895     for n in count(1):
%o A371895         t = str(pn)
%o A371895         yield next(k for k in count(1) if t in str(n*k))
%o A371895         pn = nextprime(pn)
%o A371895 print(list(islice(agen(), 70))) # _Michael S. Branicky_, Apr 11 2024
%o A371895 (PARI) a(n) = my(k=1, s=Str(prime(n))); while(#strsplit(Str(k*n), s) < 2, k++); k; \\ _Michel Marcus_, Apr 11 2024
%Y A371895 Cf. A000040, A086064.
%K A371895 nonn,base,look
%O A371895 1,1
%A A371895 _Giorgos Kalogeropoulos_, Apr 11 2024