%I #6 Jul 14 2012 14:08:26
%S 2,1,2,3,5,4,7,4,4,6,2,8,14,8,8,4,17,7,26,7,6,12,6,14,14,16,2,27,6,33,
%T 6,36,26,7,33,18,2,18,6,36,2,18,14,20,25,14,25,0,22,24,34,16,46,61,18,
%U 7,25,38,47,47,54,79,157,97,28,23,7,137,24,46,36,25,2,214,94,40,2,96
%N Smallest k such that n!+k!1 is prime, or 0 if no such k exists.
%C It is possible to prove a(48)=0: since 67 divides 48!1 and thus all 48!+k!1 for k>=67 are composite, it is sufficient to test all k<67 which was done by _Robert G. Wilson v_. Likewise 113 divides 111!1, 797 divides 128!1, 137 divides 135!1, 163 divides 161!1 etc. and therefore a(111)=a(128)=a(135)=a(161)=0.
%C From the previous comments follows that a(n)=0 if there is no k smaller than the smallest prime factor of n!1 such that n!+k!1 is prime.
%e 4!=24, 1!=1 but 24+11=24 is not prime. 24+2!1=25, not prime 24+3!1=29, prime, so a[4]=3
%t a = {}; Do[k = 1; While[ ! PrimeQ[n! + k!  1], k++ ]; a = Append[a, k], {n, 1, 47}]
%o (PARI) for (a=1,100,c=0; for (b=1,200, if (isprime(a!+b!1),c=b; break)); if (c>0,print1(c,","),print1("0,")))
%K nonn
%O 1,1
%A _Jon Perry_, Oct 08 2002
%E Edited by _Ralf Stephan_, Jun 01 2005
