/// <summary> // Check if a number is prime /// </summary> public PandigitalPrime() { //Usando la regla de los nueves, que dice que la suma de todos los digitos de un número hasta su ultima expresión, //Si el resultado es nueve el número es divisible entre 9. //Por lo tanto no hay pandigital de n=9 y n=8 //El más grande debe estar n=7 pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 7000000, 8000000 }); }
/// <summary> /// Creates a new problem /// </summary> public PrimeDigitReplacement(long familySize = 8) { this.Limit = familySize; pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 100000, 1000000 }); Permutation p = new Permutation("YYYXXX"); //La combinación de permutaciones FamilyPermutations = p.Permutations.Distinct().OrderBy <String, String>(x => x); Primes = pReader.SmallerThan(1000000).Where(x => x > 100000).ToArray(); }
/// <summary> /// Creates a new problem /// </summary> public PrimePermutations() { Console.WriteLine("Calculando Permutaciones..."); pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 999, 10000 }); Stopwatch sw = new Stopwatch(); sw.Start(); FindPrimePermutations(); sw.Stop(); Console.WriteLine("Elapsed: {0}s, {1}ms", sw.Elapsed.Seconds, sw.Elapsed.Milliseconds); }
/// <summary> /// Creates a new problem /// </summary> /// <param name="consecSize">The size of consec numbers</param> public DistinctPrimesFactors(int consecSize = 4) { ConsecNumbers = new KeyValuePair <long, int> [consecSize]; this.Size = consecSize; FactorFinder f; pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 0, 10000000 }); for (int i = 0; i < consecSize; i++) { f = new FactorFinder(i + 1); f.FindPrimes(pReader.SmallerThan(i + 2)); ConsecNumbers[i] = new KeyValuePair <long, int>(i + 1, f.Primes.Keys.Count); } }
public ConsecutivePrimes(long limit = 1000000) { this.Limit = limit; pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 0, limit }); }
public PrimePairSets() { pReader1 = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 0, MAX_PRIME }); pReader2 = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE_2)), new long[] { MAX_PRIME, MAX_PRIME * 2 }); Primes = pReader1.SmallerThan(LIMIT); }
/// <summary> /// Find the Goldbach error /// </summary> public GoldbachError() { pReader = new PrimeFileReader(new FileInfo(Path.Combine(PRIME_PATH, PRIME_FILE)), new long[] { 0, 10000000 }); }