%I #49 Apr 24 2024 02:45:10
%S 561,1103,2465,2819,6599,29339,41039,52631,62743,172079,188459,278543,
%T 340559,488879,656599,656601,670031,1033667,1909001,2100899,3146219,
%U 5048999,6049679,8719307,10024559,10402559,10877579,11119103,12261059,14913989,15247619
%N Numbers k such that at least one of k and k+2 is composite, while for every b coprime to k*(k+2), b^(k-1) == 1 (mod k) and b^(k+1) == 1 (mod k+2).
%C These might be called "Carmichael pseudo-twin-primes".
%H Amiram Eldar, <a href="/A194231/b194231.txt">Table of n, a(n) for n = 1..10000</a>
%F For every b coprime to a(n)*(a(n)+2), 2*b^(a(n)+1) == (b^2-1)*(a(n)+2) (mod a(n)*(a(n)+2)). Conversely (_Max Alekseyev_), if for every b coprime to N*(N+2), 2*b^(N+1) == (b^2-1)*(N+2) (mod N*(N+2)), then N is in the sequence. - _Vladimir Shevelev_, Oct 14 2011
%p with(numtheory):
%p ic:= proc(n) local p;
%p if not issqrfree(n) then false
%p else for p in factorset(n) do
%p if irem (n-1, p-1)<>0 then return false fi
%p od; true
%p fi
%p end:
%p a:= proc(n) option remember; local k;
%p for k from 2 +`if`(n=1, 1, a(n-1)) by 2 while
%p isprime(k) and isprime(k+2) or not (ic(k) and ic(k+2))
%p do od; k
%p end:
%p seq(a(n), n=1..10); # _Alois P. Heinz_, Oct 12 2011
%t terms = 31; bMax = 20(* sufficient for 31 terms *); coprimes[n_] := Select[ Range[bMax], CoprimeQ[#, n]&]; Reap[For[n = m = 1, m <= terms, n += 2, If[CompositeQ[n] || CompositeQ[n+2], If[AllTrue[coprimes[n(n+2)], PowerMod[#, n-1, n] == 1 && PowerMod[#, n+1, n+2] == 1&], Print["a(", m, ") = ", n]; Sow[n]; m++]]]][[2, 1]] (* _Jean-François Alcover_, Mar 28 2017 *)
%Y Cf. A002997, A001567, A141232.
%Y Subsequences: A272754, A290692.
%K nonn
%O 1,1
%A _Vladimir Shevelev_, Oct 12 2011