static void Main(string[] args) { PrimeGenerator pg = new PrimeGenerator(); double target = 15499d/94744d; double totient = 1d; double denominator = 1d; long answer = 0; for (int p = 2; ; ) { totient *= p - 1; denominator *= p; do { p++; } while (!pg.CheckPrime(p)); if (totient / denominator < target) { for (int j = 1; j < p; j++) { if ((j * totient) / (j * denominator - 1) < target) { answer = j * (long)denominator; Console.WriteLine("Result is {0}", answer); return; } } } } }
static void Main(string[] args) { FactorsGenerator fg = new FactorsGenerator(); PrimeGenerator pg = new PrimeGenerator(); Queue<long> consecutives = new Queue<long>(); for (long num = 1000; ; num++) { List<long> factors = fg.GeneratorDistinctFactors(num); if (factors.Count != 4) continue; bool allprime = true; foreach (long factor in factors) { if (pg.CheckPrime((int)factor)) continue; allprime = false; break; } if (!allprime) continue; consecutives.Enqueue(num); if (CheckConsecutive(consecutives,4)) break; if (consecutives.Count == 4) consecutives.Dequeue(); } Console.WriteLine(string.Format("Result is {0}", consecutives.Peek())); }
public void CheckPrimeTest() { PrimeGenerator target = new PrimeGenerator(); // TODO: 初始化为适当的值 int number = 0; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; for (int i = 3; i <= int.MaxValue; i+=2) { if (target.CheckPrime(i)) { Console.Write(i + " , "); } } }
static void Main(string[] args) { PrimeGenerator target = new PrimeGenerator(); int i = 3; int index = 1; while (true) { if (target.CheckPrime(i)) { index++; } if (index == 10001) { Console.WriteLine(i); break; } i += 2; } Console.ReadLine(); }