%I #43 Sep 10 2018 13:36:06
%S 2,2,3,7,10,13,13,13,31,37,37,37,61,61,61,83,83,83,127,127,127,127,
%T 127,179,179,179,179,179,193,193,193,193,193,193,193,193,277,277,277,
%U 277,277,277,383,383,383,383,383,479,479,479,479,479,479,479,541,541,541,541,541,541,541,541,541,641,641,641,641,641,641,641,641,641,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,1013,1013,1013,1013,1013,1013,1013,1013,1013,1013,1013
%N Least integer m>1 such that those k! mod m with k=1,...,n are pairwise distinct.
%C On Feb 27 2012 Zhi-Wei Sun conjectured that a(n) is a prime with the only exception a(5)=10, and that a(n) does not exceed n^2/2 for all n=2,3,4,... He also conjectured that max{n>0: 1!,...,n! are pairwise incongruent mod p} is asymptotically equivalent to sqrt(p), where p is an odd prime.
%C He guessed that if we replace k! in the definition of a(n) by (-1)^k*k! then a(n) is a prime with the only exception a(3)=6. If we replace k! in the definition of a(n) by (2k)! or (-1)^k*(2k)!, then Zhi-Wei Sun conjectured that a(n) will take only prime values.
%C He also has similar conjectures involving (r*k)! or (-1)^k*(r*k)! with r>2.
%H Zhi-Wei Sun and Charles R Greathouse IV, <a href="/A208494/b208494.txt">Table of n, a(n) for n = 1..10000</a> (first 400 terms from Sun)
%H Zhi-Wei Sun, <a href="https://listserv.nodak.edu/cgi-bin/wa.exe?A2=NMBRTHRY;df748f41.1202">A function taking only prime values</a>, a message to Number Theory List, Feb 21 2012.
%H Zhi-Wei Sun, <a href="http://dx.doi.org/10.1016/j.jnt.2013.02.003">On functions taking only prime values</a>, J. Number Theory 133(2013), no.8, 2794-2812.
%e For n=5 we have a(5)=10 since 1!=1, 2!=2, 3!=6, 4!=24 and 5!=120 are pairwise incongruent mod 10 but not pairwise incongruent modulo any of 2,3,...,9.
%t R[n_,i_]:=Union[Table[Mod[k!,i],{k,1,n}]]
%t Do[Do[If[Length[R[n,i]]==n,Print[n," ",i];Goto[aa]],{i,2,Max[n^2,2]}];
%t Print[n];Label[aa];Continue,{n,1,1000}]
%o (PARI) has(n,m)=my(t=1); #Set(vector(n,i,t=(t*i)%m))==n
%o a(n,last=2)=while(!has(n,last), last++); last
%o t=2;vector(100,n,t=a(n,t)) \\ _Charles R Greathouse IV_, Jul 31 2016
%Y Cf. A000142, A207982.
%K nonn,nice
%O 1,1
%A _Zhi-Wei Sun_, Feb 27 2012