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.

A319596 Base-3 deletable primes (written in base 10).

This page as a plain text file.
%I A319596 #54 Jan 14 2022 10:34:35
%S A319596 2,5,7,11,17,19,23,29,47,53,59,61,71,73,83,89,101,107,137,167,173,179,
%T A319596 181,191,197,223,233,251,263,269,317,431,461,491,503,509,521,541,547,
%U A319596 557,569,587,593,653,659,673,677,683,701,709,719,809,911,947,953
%N A319596 Base-3 deletable primes (written in base 10).
%C A319596 A prime p is a base-b deletable prime if when written in base b it has the property that removing some digit leaves either the empty string or another deletable prime.
%C A319596 Deleting a digit cannot leave any leading zeros in the new string. For example, deleting the 2 in 2003 to obtain 003 is not allowed.
%H A319596 Robert Israel, <a href="/A319596/b319596.txt">Table of n, a(n) for n = 1..10000</a> (first 177 terms from Robert Price)
%p A319596 S:= {2}: count:= 0:
%p A319596 p:= 2;
%p A319596 while count < 200 do
%p A319596   p:= nextprime(p);
%p A319596   d:= floor(log[3](p));
%p A319596   for i from 0 to d do
%p A319596     x:= p mod 3^(i+1);
%p A319596     q:= (x mod 3^i) + (p-x)/3;
%p A319596     if q >= 3^(d-1) and member(q,S) then
%p A319596        S:= S union {p}; count:= count+1; break
%p A319596       fi
%p A319596   od;
%p A319596 od:
%p A319596 sort(convert(S,list)); # _Robert Israel_, Nov 26 2020
%t A319596 b = 3; d = {};
%t A319596 p = Select[Range[2, 10000], PrimeQ[#] &];
%t A319596 For[i = 1, i <= Length[p], i++,
%t A319596   c = IntegerDigits[p[[i]], b];
%t A319596   If[Length[c] == 1, AppendTo[d, p[[i]]]; Continue[]];
%t A319596   For[j = 1, j <= Length[c], j++,
%t A319596    t = Delete[c, j];
%t A319596    If[t[[1]] == 0, Continue[]];
%t A319596    If[MemberQ[d, FromDigits[t, b]], AppendTo[d, p[[i]]]; Break[]]]];
%t A319596 d (* _Robert Price_, Dec 05 2018 *)
%o A319596 (Python)
%o A319596 from sympy import isprime
%o A319596 from sympy.ntheory.digits import digits
%o A319596 def ok(n, base=3):
%o A319596     if not isprime(n): return False
%o A319596     if n < 3: return True
%o A319596     s = "".join(str(d) for d in digits(n, base)[1:])
%o A319596     si = (s[:i]+s[i+1:] for i in range(len(s)))
%o A319596     return any(t[0] != '0' and ok(int(t, base)) for t in si)
%o A319596 print([k for k in range(954) if ok(k)]) # _Michael S. Branicky_, Jan 14 2022
%Y A319596 Cf. A080608, A080603, A096235-A096246.
%K A319596 nonn,base,easy
%O A319596 1,1
%A A319596 _Robert Price_, Nov 14 2018
%E A319596 Removed the term 3. As pointed out by _Kevin Ryde_, there is no need to "seed" the list using base-2 assumptions. - _Robert Price_, Dec 05 2018