public static long Solution() { var stopwatch = new System.Diagnostics.Stopwatch(); long solution = 0; var divisorsOfOrder = UtilityFunctions.Divisors(order); var primes = UtilityFunctions.Primes((int)Math.Sqrt(UtilityFunctions.IntegralPower(2, order / 2) + 1)); var primeFactors = UtilityFunctions.PrimeFactors(UtilityFunctions.IntegralPower(2, order) - 1, primes); var reducedPrimes = primeFactors.Select(t => t.Item1).ToList(); foreach (var d in divisorsOfOrder) { var m = UtilityFunctions.Moebius(d, null, primes); if (m != 0) { var divisorsOfPowerOfTwo = UtilityFunctions.Divisors(UtilityFunctions.IntegralPower(2, order / d) - 1, null, reducedPrimes); solution += (divisorsOfPowerOfTwo.Sum() + divisorsOfPowerOfTwo.Count()) * m; } } return(solution); }