private int GetDenominatorOfFractionsProduct() { int numeratorProduct = 1; int denominatorProduct = 1; for (int i = 10; i <= 98; ++i) { for (int j = i + 1; j <= 99; ++j) { if (IsNonTrivialExample(i, j)) { numeratorProduct *= i; denominatorProduct *= j; } } } if (denominatorProduct % numeratorProduct == 0) { return(denominatorProduct / numeratorProduct); } ESieve sieve = new ESieve((int)Math.Max(numeratorProduct, denominatorProduct)); PrimeDivisors numPrimeDivisors = new PrimeDivisors(numeratorProduct, sieve); PrimeDivisors denPrimeDivisors = new PrimeDivisors(denominatorProduct, sieve); int gcp = numPrimeDivisors.GetGCP(numPrimeDivisors); return(denominatorProduct / gcp); }
public int Run() { int number = 378; while (true) { PrimeDivisors div1 = new PrimeDivisors(number, sieve); List <int> factors1 = div1.GetFactors(); if (factors1.Count == FACTORS_COUNT) { PrimeDivisors div2 = new PrimeDivisors(number + 1, sieve); List <int> factors2 = div2.GetFactors(); if (factors2.Count == FACTORS_COUNT) { if (!AreDistinct(factors1, factors2)) { number++; } else { PrimeDivisors div3 = new PrimeDivisors(number + 2, sieve); List <int> factors3 = div3.GetFactors(); if (factors3.Count == FACTORS_COUNT) { if (!AreDistinct(factors2, factors3)) { number += 2; } else if (!AreDistinct(factors1, factors3)) { number++; } else { PrimeDivisors div4 = new PrimeDivisors(number + 3, sieve); List <int> factors4 = div4.GetFactors(); if (factors4.Count == FACTORS_COUNT) { if (!AreDistinct(factors3, factors4)) { number += 3; } else if (!AreDistinct(factors2, factors4)) { number += 2; } else if (!AreDistinct(factors1, factors4)) { number++; } return(number); } else { number += 4; } } } else { number += 3; } } } else { number += 2; } } else { number++; } } }