public BigInteger Solve(BigInteger?input = null) { bool[] primesUnderAMillion = PrimeHelper.FindPrimesUnderLimit(1000000); BigInteger result = 0; for (int i = 2; i < 1000000; i++) { var testNumber = i; var circular = true; var testString = testNumber.ToString(); for (int j = 0; j <= i.ToString().Length + 1; j++) { if (!primesUnderAMillion[testNumber] || testNumber > 1000000) { circular = false; break; } testString = testString.Insert(testString.Length, testString.Substring(0, 1)); testString = testString.Remove(0, 1); testNumber = int.Parse(testString); } if (circular) { result++; } } return(result); }
public BigInteger Solve(BigInteger?input = null) { int result = 0; int primesLimit = 100000; while (result == 0) { BigInteger numberOfPrimes = 0; bool[] test = PrimeHelper.FindPrimesUnderLimit(primesLimit); for (int i = 0; i < test.Length; i++) { if (test[i]) { numberOfPrimes++; if (numberOfPrimes == input) { result = i; } } } primesLimit += 100000; } return(result); }
public BigInteger Solve(BigInteger?input = null) { bool[] primesUnderLimit = PrimeHelper.FindPrimesUnderLimit(2000000); BigInteger total = 0; for (int i = 0; i < primesUnderLimit.Length; i++) { if (primesUnderLimit[i]) { total += i; } } return(total); }
public BigInteger Solve(BigInteger?input = null) { var primes = PrimeHelper.FindPrimesUnderLimit(28124); List <int> abundantNumbers = new List <int>(); for (int i = 2; i < 28124; i++) { if (DivisorsHelper.SumOfProperDivisors(i, primes) > i) { abundantNumbers.Add(i); } } BigInteger result = 0; bool[] canBeSummed = new bool[28124]; for (int i = 0; i < abundantNumbers.Count; i++) { for (int j = 0; j < abundantNumbers.Count; j++) { if (abundantNumbers[i] + abundantNumbers[j] >= 28124) { break; } canBeSummed[abundantNumbers[i] + abundantNumbers[j]] = true; } } for (int i = 1; i < 28124; i++) { if (!canBeSummed[i]) { result += i; } } return(result); }
public BigInteger Solve(BigInteger?input = null) { // b must be prime for the case when n = 0; -- this must make it easier, // b + a + 1 must be prime -- does this? IT TURNS OUT IT DOES, as long as b isn't 2 a must be odd // n^2 + an + b = p var primesUnder2Million = PrimeHelper.FindPrimesUnderLimit(2000000); int highestIndex = 39, bestABProduct = 41; // skip even version of a, hope a isn't 2 for (int a = -999; a < 1000; a += 2) { int b = 3; while (b < 1000) { // b has to be prime! if (primesUnder2Million[b]) { int i = 0; // iterate to see how deep the rabbit hole goes for this combination of a and b while (i * i + a * i + b > 0 && primesUnder2Million[i * i + a * i + b]) { i++; } // we have a highestindex if (i > highestIndex) { highestIndex = i; bestABProduct = a * b; } } b++; } } return(bestABProduct); }
public BigInteger Solve(BigInteger?input = null) { BigInteger result = 0; bool[] primesUnderLimit = PrimeHelper.FindPrimesUnderLimit(10001); for (int i = 2; i < 10000; i++) { if (primesUnderLimit[i]) { continue; } BigInteger sumOfDivisors = DivisorsHelper.SumOfDivisors(i, primesUnderLimit) - i; if (sumOfDivisors < 10000 && sumOfDivisors != i && DivisorsHelper.SumOfDivisors((int)sumOfDivisors, primesUnderLimit) - sumOfDivisors == i) { result += i; } } return(result); }
public BigInteger Solve(BigInteger?input = null) { int numberOfDivisors = 0; int i = 2, triangleNumber = 1; while (numberOfDivisors < 500) { numberOfDivisors = 0; triangleNumber += i; int testNumber = triangleNumber; Dictionary <int, int> divisors = DivisorsHelper.CalculatePrimeDivisors(testNumber, PrimeHelper.FindPrimesUnderLimit(200000000)); numberOfDivisors = divisors.Values.ElementAt(0) + 1; for (int l = 1; l < divisors.Count; l++) { numberOfDivisors *= divisors.Values.ElementAt(l) + 1; } i++; } return(triangleNumber); }