A317248 Semiprimes which when truncated arbitrarily on either side in base 10 yield semiprimes.
4, 6, 9, 46, 49, 69, 94, 469, 694, 949, 4694
Offset: 1
Examples
4694 is a semiprime (2 * 2347), and its truncations are, too: 469 (7 * 67), 694 (2 * 347), 46 (2 * 23), etc.
Links
- Keith J. Bauer, "A317248 (Python v2.7.13)"
Programs
-
Mathematica
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 *)
-
Python
#v2.7.13, see LINKS to run it online. #semitest(number, 0) returns True iff number is a semiprime def semitest(number, factors): if number != 2: for p in [2] + range(3, int(number ** 0.5) + 1, 2): if number % p == 0: if factors < 2: return semitest(number / p, factors + 1) else: return False if factors == 1: return True else: return False #main function def doIt(base): #initialization numbers = [[]] indices_list = [[]] i = 0 for number in range(1, base): if semitest(number, 0): numbers[0].append(number) indices_list[0].append([i]) i += 1 #numbers[0] is the digit pool #numbers[-1] is to be appended to #numbers[-2] is for reference to past numbers #indices_list records the indices of numbers numbers.append([]) indices_list.append([]) #main while loop, go until there are no numbers left in the sequence indices = [0, 0] while len(numbers[-2]) > 0: #test number if indices[:-1] in indices_list[-2]: if indices[1:] in indices_list[-2]: #little-endian number = 0 power = 0 for index in indices: number += numbers[0][index] * base ** power power += 1 if semitest(number, 0): numbers[-1].append(number) indices_list[-1].append(indices[:]) #increment indices for i in range(len(indices)): indices[i] += 1 if indices[i] == len(numbers[0]): indices[i] = 0 if i == len(indices) - 1: indices = [0] * len(indices) + [0] numbers.append([]) indices_list.append([]) else: break #print results after while loop has run print base, sum(numbers, []) print numbers #call main function doIt(10)
-
Python
from sympy import factorint A317248_list = xlist = [4,6,9] for n in range(1,10): ylist = [] for i in (4,6,9): for x in xlist: if sum(factorint(10*x+i).values()) == 2 and (10*x+i) % 10**n in xlist: ylist.append(10*x+i) elif sum(factorint(x+i*10**n).values()) == 2 and (x//10+i*10**(n-1)) in xlist: ylist.append(x+i*10**n) xlist = set(ylist) if not len(xlist): break A317248_list.extend(xlist) A317248_list.sort() # Chai Wah Wu, Aug 23 2018
Comments