A345666 Composite numbers whose largest prime substring is greater than the record of all previous terms.
12, 15, 27, 110, 117, 119, 123, 129, 141, 143, 147, 153, 159, 161, 171, 183, 189, 297, 1010, 1030, 1070, 1090, 1113, 1127, 1131, 1137, 1139, 1149, 1157, 1167, 1173, 1179, 1191, 1197, 1199, 1211, 1227, 1233, 1239, 1241, 1251, 1257, 1263, 1269, 1271, 1281, 1293
Offset: 1
Examples
a(1)=12 is the first composite containing a prime substring. Its largest prime substring is A345667(1)=2. It is the first nonzero composite index of A047814.
Programs
-
Mathematica
lst={};max=m=0;Do[If[!PrimeQ@n,If[IntegerQ[s=Max@Select[FromDigits/@Subsequences@IntegerDigits@n,PrimeQ]],m=s]];If[m>max,max=m;AppendTo[lst,n]],{n,10000}];lst (* Giorgos Kalogeropoulos, Jun 25 2021 *)
-
Python
def trojan_composites(limit_maxval=None, limit_terms=None, verbose=True): from sympy import isprime num = 1 best = 0 found = [] while (not limit_maxval or num <= limit_maxval) and (not limit_terms or len(found) < limit_terms): num += 1 if not isprime(num): string = str(num) for length in range(len(string), len(str(best)), -1): candidate = max(filter(isprime, {int(string[i:i + length - 1]) for i in range(len(string) - length + 2)}), default=0) if candidate: if candidate > best: best = candidate found.append(num) if verbose: print(num, end=', ', flush=True) break if verbose: print() return found trojan_composites(limit_terms=7) #[12, 15, 27, 110, 117, 119, 123]