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.

A375614 Lexicographically earliest infinite sequence of distinct nonnegative pairs of terms that interpenetrate to produce a prime number.

This page as a plain text file.
%I A375614 #46 Aug 25 2024 04:28:32
%S A375614 0,11,3,17,2,23,6,13,1,21,4,19,7,27,5,33,8,39,103,10,153,20,107,12,
%T A375614 131,15,109,16,111,26,113,24,101,30,119,14,123,25,117,29,141,22,127,
%U A375614 18,133,31,129,28,121,34,169,36,137,32,167,38,147,35,171,43,157,37,9,41,149,44,159,55,139,46,151,45,163,48,173,42,143,51,187,49,177,52,183,50,161,54,179,47,189
%N A375614 Lexicographically earliest infinite sequence of distinct nonnegative pairs of terms that interpenetrate to produce a prime number.
%C A375614 The term a(n) must always be exactly one digit longer or shorter than the term a(n+1).
%H A375614 Michael S. Branicky, <a href="/A375614/b375614.txt">Table of n, a(n) for n = 1..10000</a>
%H A375614 Eric Angelini, <a href="https://cinquantesignes.blogspot.com/2024/08/combs-and-pharaohs.html">Combs and Pharaohs</a>, personal blog of the author.
%e A375614 Interpenetrate a(1) = 0 and a(2) = 11 to form 101 (a prime number);
%e A375614 interpenetrate a(2) = 11 and a(3) = 3 to form 131 (a prime number);
%e A375614 interpenetrate a(3) = 3 and a(4) = 17 to form 137 (a prime number);
%e A375614 interpenetrate a(4) = 17 and a(5) = 2 to form 127 (a prime number);
%e A375614 interpenetrate a(5) = 2 and a(6) = 23 to form 223 (a prime number);
%e A375614 interpenetrate a(6) = 23 and a(7) = 6 to form 263 (a prime number);
%e A375614 interpenetrate a(7) = 6 and a(8) = 13 to form 163 (a prime number);
%e A375614 interpenetrate a(8) = 13 and a(9) = 1 to form 113 (a prime number);
%e A375614 (...)
%e A375614 interpenetrate a(18) = 39 and a(19) = 103 to form 13093 (a prime number);
%e A375614 (...)
%e A375614 interpenetrate a(167) = 277 and a(168) = 1009 to form 1207079 (a prime number); etc.
%p A375614 Q:= proc(a,b) local La, Lb, i;
%p A375614   La:= convert(a,base,10);
%p A375614   Lb:= convert(b,base,10);
%p A375614   add(La[i]*10^(2*i-2),i=1..nops(La)) + add(Lb[i]*10^(2*i-1),i=1..nops(Lb))
%p A375614 end proc:
%p A375614 f:= proc(n) local d,x;
%p A375614   d:= 1+ilog10(n);
%p A375614   if n::odd then
%p A375614     for x from 10^(d-2) to 10^(d-1) - 1 do
%p A375614       if not(member(x,S)) and isprime(Q(n,x)) then return x fi
%p A375614     od
%p A375614   fi;
%p A375614   for x from 10^d+1 to 10^(d+1) - 1 by 2 do
%p A375614     if not(member(x,S)) and isprime(Q(x,n)) then return x fi
%p A375614   od;
%p A375614 FAIL
%p A375614 end proc:
%p A375614 R:= 0,11: S:= {0,11}: v:= 11:
%p A375614 for i from 2 to 100 do
%p A375614   v:= f(v);
%p A375614   R:= R,v;
%p A375614   S:= S union {v};
%p A375614 od:
%p A375614 R; # _Robert Israel_, Aug 22 2024
%o A375614 (Python)
%o A375614 from sympy import isprime
%o A375614 from itertools import islice
%o A375614 def ip(s, t): return int("".join(x+v for x, v in zip(s, t))+s[-1])
%o A375614 def agen(): # generator of terms
%o A375614     seen, an, found = set(), 0, True
%o A375614     while found:
%o A375614         yield an
%o A375614         seen.add(an)
%o A375614         s = str(an)
%o A375614         d, found = len(s), False
%o A375614         if s[-1] in "1379" and d > 1:
%o A375614             for k in range(10**(d-2), 10**(d-1)):
%o A375614                 if k not in seen and isprime(ip(s, str(k))):
%o A375614                     an, found = k, True
%o A375614                     break
%o A375614         if not found:
%o A375614             for k in range(10**d, 10**(d+1)):
%o A375614                 if k not in seen and isprime(ip(str(k), s)):
%o A375614                     an, found = k, True
%o A375614                     break
%o A375614 print(list(islice(agen(), 90))) # _Michael S. Branicky_, Aug 22 2024
%Y A375614 Cf. A213457, A000040.
%K A375614 base,nonn,look
%O A375614 1,2
%A A375614 _Eric Angelini_ and _Jean-Marc Falcoz_, Aug 22 2024