public static int truncatableprimes(int n) { int count = 0; int sum = 0; PrimeFunctions.GeneratePrimesToList(1000000); PrimeFunctions.ConvertToHash(); int i = 4; while (count < n) { bool isprime = true; List <int> trunc = CombinatoricFunctions.truncations(PrimeFunctions.PrimeList[i]); foreach (int truncation in trunc) { if (!PrimeFunctions.PrimeListHash.Contains(truncation)) { isprime = false; break; } } if (isprime) { count++; sum += PrimeFunctions.PrimeList[i]; } i++; } return(sum); }
public static int DistinctPrimeFactors() { PrimeFunctions.GeneratePrimesToList(100000); int i = 2; int count = 0; while (count < 4) { i++; List <int> primes = PrimeFunctions.PrimeFactor(i); HashSet <int> factors = MiscFunctions.ListToHash(primes); if (factors.Count == 4) { count++; } else { count = 0; } } return(i - 3); }