public void Solve() { var arrVals = new Dictionary <Int32, Int64>(max); List <long> factorization; int lastFactor; int product; for (int i = 1; i <= max; i++) { product = 1; lastFactor = 1; factorization = prm.PrimeFactorization(i); foreach (int val in prm.PrimeFactorization(i)) { if (val != lastFactor) { product *= val; lastFactor = val; } } arrVals.Add(i, product); } var sorted = arrVals.OrderBy(key => key.Value).ThenBy(key => key.Key); Console.WriteLine(sorted.ToList()[want - 1]); }
public void SetData() { C = (reflections + 3) / 2; primes = new Primes((long)Math.Ceiling(Math.Max((double)Math.Sqrt(C), 10000D))); cFactorization = primes.PrimeFactorization(C); eMax = EMax(); eMin = EMin(eMax); // We'll start considering all values, then subtract off invalid values. count = ((eMax - eMin) / 3) + 1; evaluatedFactors = new HashSet <long>(); }