static void Main(string[] args) { mpz_t tot = P / 3; for (mpz_t roota = 1; roota <= P.Sqrt(); roota++) { if (roota % 1000 == 0) { Console.Write($"\r{roota} : {P.Sqrt()}"); } for (mpz_t rootc = roota + 1; ; rootc++) { mpz_t a = roota.Power(2); mpz_t c = rootc.Power(2); mpz_t b = roota.Multiply(rootc); if (a + b + c > P || c > a + b) { break; } //if (mpz_t.Gcd(a, c) == 1) { Console.WriteLine($"{a},{b},{c} {roota} / {rootc}{(mpz_t.Gcd(a,c) > 1 ? " M" : "")}"); tot += P.Divide(a + b + c); } } Console.WriteLine(); } Console.WriteLine(tot); }
static int NumPrimes(int a, int b) { for (int n = 0; ; n++) { mpz_t bign = new mpz_t(n); mpz_t p = bign.Power(2) + bign.Multiply(a) + b; if (!p.IsProbablyPrimeRabinMiller(10)) { return(n); } } }