private static long GetMaxPrimeDividerRequrse(long input) { long maxValue = (long)Math.Sqrt(input); long maxDivider = input; var primeEnum = new PrimeSequenceAlt().GetPrimeEnumerator(); long counter = 0; long divided; while (primeEnum.MoveNext() && primeEnum.Current <= maxValue) { if (TestDivide(input, primeEnum.Current, out divided)) { maxDivider = primeEnum.Current; if (divided > maxDivider) { divided = GetMaxPrimeDividerRequrse(divided); } return(Math.Max(maxDivider, divided)); } counter++; } //Console.WriteLine("Prime count: " + counter + " last " + primeEnum.Current); return(maxDivider); }
private static long GetPrimeById(long count) { var primeEnum = new PrimeSequenceAlt().GetPrimeEnumerator(); for (long i = 0; i < count; i++) { primeEnum.MoveNext(); } return(primeEnum.Current); }