%I #43 Apr 22 2024 14:28:47
%S 561,1105,1729,561,1105,561,1729,6601,2465,2821,29341,6601,334153,
%T 62745,2433601,74165065,29341,8911,10024561,10585,2508013,55462177,
%U 62745,46657,101101,52633,84350561,188461,278545,1152271,18307381,410041,2628073,12261061,838201
%N a(n) is the smallest Carmichael number (A002997) divisible by the n-th prime, or 0 if no such number exists.
%H Amiram Eldar, <a href="/A135721/b135721.txt">Table of n, a(n) for n = 2..10001</a> (calculated using data from Claude Goutier; terms 2..1000 from Donovan Johnson)
%H Claude Goutier, <a href="http://www-labs.iro.umontreal.ca/~goutier/OEIS/A055553/">Compressed text file carm10e22.gz containing all the Carmichael numbers up to 10^22</a>.
%H GĂ©rard P. Michon, <a href="http://www.numericana.com/data/korselt.htm">Carmichael Multiples of Odd Primes</a>.
%H <a href="/index/Ca#Carmichael">Index entries for sequences related to Carmichael numbers</a>.
%e 561 is the first Carmichael number and its prime factors are 3, 11, 17 (2nd, 5th and 7th primes), so a(2), a(5) and a(7) are equal to 561. - _Michel Marcus_, Nov 07 2013
%t c = Cases[Range[1, 10000000, 2], n_ /; Mod[n, CarmichaelLambda@ n] == 1 && ! PrimeQ@ n]; Table[First@ Select[c, Mod[#, Prime@ n] == 0 &], {n, 2, 16}] (* _Michael De Vlieger_, Aug 28 2015, after _Artur Jasinski_ at A002997 *)
%o (PARI) Korselt(n)=my(f=factor(n)); for(i=1, #f[, 1], if(f[i, 2]>1||(n-1)%(f[i, 1]-1), return(0))); 1
%o isA002997(n)=n%2 && !isprime(n) && Korselt(n) && n>1
%o a(n) = my(pn=prime(n),cn = 31*pn); until (isA002997(cn+=2*pn),); cn; \\ _Michel Marcus_, Nov 07 2013, improved by _M. F. Hasler_, Apr 14 2015
%o (PARI) Korselt(n)=my(f=factor(n)); for(i=1, #f[, 1], if(f[i, 2]>1||(n-1)%(f[i, 1]-1), return(0))); 1
%o a(n,p=prime(n))=my(m=lift(Mod(1/p,p-1)),c=max(m,33)*p,mp=m*p); while(!isprime(c) && !Korselt(c), c+=mp); c \\ _Charles R Greathouse IV_, Apr 15 2015
%Y Cf. A002997, A135717, A006931, A135719, A135720.
%K nonn
%O 2,1
%A _Artur Jasinski_, Nov 25 2007
%E More terms from _Michel Marcus_, Nov 07 2013
%E Escape clause added by _Jianing Song_, Dec 12 2021