%I #77 Nov 25 2021 12:35:25
%S 20,50,284,1868,47951,6245927,15932178151
%N a(n) is the smallest k such that f(k) is composite for all m-fold compositions f of the functions 6*x +- 1, 1 <= m <= n.
%C Proof that a(n) exists for all n: The numbers that are equal to f(k) for some m-fold composition f of the functions 6*x +- 1 can be written as 6^m*k +- c, where c is in the set C_m, defined by C_1 = {1} and C_{m+1} = {6*c +- 1 for c in C_m}. Choose a positive integer k_0 that is divisible by all numbers in C_m for 1 <= m <= n. Then 6^m*k_0 +- c is divisible by (and greater than) c, so it is composite if c > 1. (In fact, the largest number in C_m is A003464(m).) Since there are arbitrarily long prime gaps, we can choose a positive integer r such that 6*k_0*r +- 1 are both composite. With k = k_0*r, the numbers 6^m*k +- c will all be composite for c in C_m, 1 <= m <= n, as desired. - _Pontus von Brömssen_, Nov 01 2021
%e Formula for the twin composites by iteration n:
%e n=1: 6*k+-1.
%e n=2: 6*(6*k+-1)+-1.
%e n=3: 6*(6*(6*k+-1)+-1)+-1.
%e Term a(n) example for smallest number k for iteration n:
%e a(1)=20, 6*20-1=119, 6*20+1=121, all {119,121} are composite numbers.
%e a(2)=50, 6*50-1=299, 6*50+1=301, 6*(6*50-1)-1=1793, 6*(6*50-1)+1=1795, 6*(6*50+1)-1=1805, 6*(6*50+1)+1=1807, all {299,301,1793,1795,1805,1807} are composite numbers.
%t a[n_] := Module[{k = 1}, While[!AllTrue[Flatten@ Rest@ NestList[Flatten@ Join[{6*# - 1, 6*# + 1}] &, k, n], CompositeQ], k++]; k]; Array[a, 5] (* _Amiram Eldar_, Oct 25 2021 *)
%o (Python)
%o from sympy import isprime
%o def A345124(n):
%o C = [[1]]
%o for i in range(n-1):
%o C.append(sum(([6*c-1,6*c+1] for c in C[-1]),[]))
%o k = 1
%o while 1:
%o k6 = 6*k
%o for i in range(n):
%o if any(isprime(k6-c) or isprime(k6+c) for c in C[i]):
%o break
%o k6 *= 6
%o else:
%o return k
%o k += 1 # _Pontus von Brömssen_, Nov 01 2021
%Y Cf. A003464, A060461 (numbers k such that 6*k+-1 are twin composites).
%K nonn,more
%O 1,1
%A _Marc Morgenegg_, Oct 06 2021
%E More terms from _Pontus von Brömssen_, Oct 06 2021
%E Name edited by _Pontus von Brömssen_, Nov 01 2021
%E a(7) from _Martin Ehrenstein_, Nov 13 2021