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.
%I A317248 #27 Aug 23 2018 20:59:19 %S A317248 4,6,9,46,49,69,94,469,694,949,4694 %N A317248 Semiprimes which when truncated arbitrarily on either side in base 10 yield semiprimes. %C A317248 There are exactly 3 1-digit terms, 4 2-digit terms, 3 3-digit terms, and 1 4-digit term. %C A317248 After the 4-digit term, there are no more terms in this sequence. This is provable by induction: There are no 5-digit terms. If there are no k-digit terms, there are no (k+1)-digit terms. (If there were, then said term, when truncated on either side, would produce a k-digit number that is in the sequence.) Therefore, there are no terms that have at least 5 digits. %C A317248 The sequence 3, 4, 3, 1, 0, 0, ... does not appear to be significant. %C A317248 This sequence depends on base 10 and is nonnegative. %C A317248 Any truncation of a number in this sequence yields another number in this sequence. If one did not, then truncating the number more would yield a non-semiprime, which is impossible. %C A317248 Base 10 is the first base in which this sequence contains 3-digit terms. %H A317248 Keith J. Bauer, <a href="http://tpcg.io/cSo9J1">"A317248 (Python v2.7.13)"</a> %e A317248 4694 is a semiprime (2 * 2347), and its truncations are, too: 469 (7 * 67), 694 (2 * 347), 46 (2 * 23), etc. %t A317248 ok[w_, n_] := AllTrue[Flatten@ Table[ FromDigits@ Take[w, {i, j}], {i, n}, {j, i, n}], PrimeOmega[#] == 2 &]; Union @@ Reap[ Do[Sow[ FromDigits /@ Select[Tuples[{4, 6, 9}, n], ok[#, n] &]], {n, 5}]][[2, 1]] (* _Giovanni Resta_, Jul 26 2018 *) %o A317248 (Python) #v2.7.13, see LINKS to run it online. %o A317248 #semitest(number, 0) returns True iff number is a semiprime %o A317248 def semitest(number, factors): %o A317248 if number != 2: %o A317248 for p in [2] + range(3, int(number ** 0.5) + 1, 2): %o A317248 if number % p == 0: %o A317248 if factors < 2: %o A317248 return semitest(number / p, factors + 1) %o A317248 else: %o A317248 return False %o A317248 if factors == 1: %o A317248 return True %o A317248 else: %o A317248 return False %o A317248 #main function %o A317248 def doIt(base): %o A317248 #initialization %o A317248 numbers = [[]] %o A317248 indices_list = [[]] %o A317248 i = 0 %o A317248 for number in range(1, base): %o A317248 if semitest(number, 0): %o A317248 numbers[0].append(number) %o A317248 indices_list[0].append([i]) %o A317248 i += 1 %o A317248 #numbers[0] is the digit pool %o A317248 #numbers[-1] is to be appended to %o A317248 #numbers[-2] is for reference to past numbers %o A317248 #indices_list records the indices of numbers %o A317248 numbers.append([]) %o A317248 indices_list.append([]) %o A317248 #main while loop, go until there are no numbers left in the sequence %o A317248 indices = [0, 0] %o A317248 while len(numbers[-2]) > 0: %o A317248 #test number %o A317248 if indices[:-1] in indices_list[-2]: %o A317248 if indices[1:] in indices_list[-2]: %o A317248 #little-endian %o A317248 number = 0 %o A317248 power = 0 %o A317248 for index in indices: %o A317248 number += numbers[0][index] * base ** power %o A317248 power += 1 %o A317248 if semitest(number, 0): %o A317248 numbers[-1].append(number) %o A317248 indices_list[-1].append(indices[:]) %o A317248 #increment indices %o A317248 for i in range(len(indices)): %o A317248 indices[i] += 1 %o A317248 if indices[i] == len(numbers[0]): %o A317248 indices[i] = 0 %o A317248 if i == len(indices) - 1: %o A317248 indices = [0] * len(indices) + [0] %o A317248 numbers.append([]) %o A317248 indices_list.append([]) %o A317248 else: %o A317248 break %o A317248 #print results after while loop has run %o A317248 print base, sum(numbers, []) %o A317248 print numbers %o A317248 #call main function %o A317248 doIt(10) %o A317248 (Python) %o A317248 from sympy import factorint %o A317248 A317248_list = xlist = [4,6,9] %o A317248 for n in range(1,10): %o A317248 ylist = [] %o A317248 for i in (4,6,9): %o A317248 for x in xlist: %o A317248 if sum(factorint(10*x+i).values()) == 2 and (10*x+i) % 10**n in xlist: %o A317248 ylist.append(10*x+i) %o A317248 elif sum(factorint(x+i*10**n).values()) == 2 and (x//10+i*10**(n-1)) in xlist: %o A317248 ylist.append(x+i*10**n) %o A317248 xlist = set(ylist) %o A317248 if not len(xlist): %o A317248 break %o A317248 A317248_list.extend(xlist) %o A317248 A317248_list.sort() # _Chai Wah Wu_, Aug 23 2018 %Y A317248 Cf. A001358. %Y A317248 Subset of A107342 and A086698. %K A317248 base,fini,full,nonn %O A317248 1,1 %A A317248 _Keith J. Bauer_, Jul 24 2018