/// <summary> /// Solves the problem /// </summary> /// <returns>The problem solution</returns> public long Solve() { Boolean IsValid = false; long count = START_TRIANGLE_INDEX; long number; Stopwatch sw = new Stopwatch(); sw.Start(); do { count++; number = TriangleNumberGenerator.Get(count); IsValid = PentagonNumbers.IsPentagonalNumber(number) && IsHexagonalNumber(number); } while (!IsValid); sw.Stop(); Console.WriteLine("Elapsed: {0}s, {1}ms", sw.Elapsed.Seconds, sw.Elapsed.Milliseconds); return(number); }
/// <summary> /// Solve the problem /// </summary> /// <returns>The sum result</returns> private long Solve() { int factorCount = 0; long tNumber = 0; int index = 1; FactorFinder factors; while (factorCount <= 500) { tNumber = TriangleNumberGenerator.Get(index); factors = new FactorFinder(tNumber); factorCount = factors.CountFactors(); index++; //Console.Clear(); //Console.WriteLine("Triangle Number: " + index); //Console.WriteLine("Index: " + index); //Console.WriteLine("Factor Count: " + factorCount); } return(tNumber); }