Requires… a prime number solver… done that earlier.. so.. actually quite an easy problem..
static void Main(string[] args)
{
// n² + an + b,
int max = 0;
int maxx = 0;
for (int a = -1000; a < 1000; a++)
{
for (int b = -1000; b < 1000; b++)
{
max = 0;
for (int n = 0; n < 500; n++) //number of primes in a row
{
int p= (n * n) + (a * n) + b;
if (isprime(p) && p> 1)
{
max++;
if (max > maxx)
{
maxx = max;
Console.WriteLine(a + "," + b + "," + maxx);
}
}
else
{
max = 0;
break;
}
}
}
}
Console.ReadLine();
}
No comments:
Post a Comment