internal uint GetFirstPrimeFactor(ulong ToTest) { if (ToTest <= 3) { return(0); } // If it's an even number. if ((ToTest & 1) == 0) { return(2); } uint Max = (uint)SquareRt.FindULSqrRoot(ToTest); for (int Count = 0; Count < PrimeArrayLength; Count++) { uint TestN = PrimeArray[Count]; if (TestN > Max) { return(0); } if ((ToTest % TestN) == 0) { return(TestN); } } return(0); }