using System;publicclassKata{publicstaticboolAmIWilson(int p){return Array.Exists(newint[]{5,13,563}, e => e == p);}}
答案2:
publicclassKata{publicstaticboolAmIWilson(int p){int pow =1;for(int i =2; i < p; i++)
pow = pow * i;if((pow +1)%(p * p)==0)returntrue;elsereturnfalse;}}
答案3:
publicclassKata{// Only 3 Wilson primes are known, others must be > 2 * 10^13 which is greater than int.MaxValue.publicstaticboolAmIWilson(int p)=> p ==5|| p ==13|| p ==563;}
答案4:
publicclassKata{publicstaticboolAmIWilson(int p){return p ==5|| p ==13|| p ==563;}}
答案5:
publicclassKata{publicstaticboolAmIWilson(int p){return(p ==5|| p ==13|| p ==563);}}
using System.Linq;publicclassKata{publicstaticboolAmIWilson(int p){return((Enumerable.Range(1, p-1).Aggregate((i1, i2)=> i1*i2)+1)%(p*p))==0?true:false;}}
答案8:
publicclassKata{publicstaticboolAmIWilson(int p){int F =1;for(int i =1; i < p; i++){
F *= i;}return((F+1)%(p*p)==0);}}
答案9:
publicclassKata{publicstaticboolAmIWilson(int p){int f =1;for(int i =1; i < p; f *= i++);return(f +1)%(p * p)==0;}}
答案10:
using System;using System.Linq;publicclassKata{publicstaticboolAmIWilson(int p)=>(1+ Enumerable.Range(1, p -1).Aggregate(1l,(a,i)=> a * i))%(p * p)==0;}
答案11:
//for type int only three exist... (http://mathworld.wolfram.com/WilsonPrime.html)publicclassKata{publicstaticboolAmIWilson(int p){return p==5||p==13||p==563;}}