Ask Your Question

Revision history [back]

You seem to be confusing symbolic variables with Python names. Since you plan to le a,b,n take som precise integer values, you should define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

You seem to be confusing symbolic variables with Python names. Since you plan to le a,b,n take som precise integer values, you should define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

Also, what are you trying to test when you write if f(n) in ZZ ?

You seem to be confusing symbolic variables with Python names. Since you plan to le let a,b,n take som precise integer values, you should better define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

Also, what are you trying to test when you write if f(n) in ZZ ?

You seem to be confusing symbolic variables with Python names. Since you plan to let a,b,n take som precise integer values, you should better define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

Also, what are you trying to test when you write if f(n) in ZZ ?

EDIT

To test a couple (a,b), you can define the function:

def test(a, b):
    return all(is_prime(n^2+a*n+b) for n in range(1,41))

Now, you can run your test for the first pairs a,b:

for a in range(41):
    for b in range(41):
        if test(a,b):
            print(a,b)

Unfortunately, you will not find any pair in that range.

You seem to be confusing symbolic variables with Python names. Since you plan to let a,b,n take som precise integer values, you should better define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

Also, what are you trying to test when you write if f(n) in ZZ ?

EDIT

To test a couple (a,b), you can define the function:

def test(a, b):
    return all(is_prime(n^2+a*n+b) for n in range(1,41))

Now, you can run your test for the first pairs a,b:

for a in range(41):
range(100):
    for b in range(41):
range(100):
        if test(a,b):
            print(a,b)

Unfortunately, you will not find any pair in that range.

You seem to be confusing symbolic variables with Python names. Since you plan to let a,b,n take som precise integer values, you should better define f = n^2+a*n+b only when a, b, n get a value, that is inside the loop.

I could help to rewrite the code, but I am not surre about your objective, do you want to find all tuples (a,b,n) in $\{1,40\} \times \{1,40\} \times \{0,40\}$ such that n^2+a*n+b is prime ?

Also, what are you trying to test when you write if f(n) in ZZ ?

EDIT

To test a couple (a,b), you can define the function:

def test(a, b):
    return all(is_prime(n^2+a*n+b) for n in range(1,41))

Now, you can run your test for the first pairs a,b:

for a in range(100):
    for b in range(100):
        if test(a,b):
            print(a,b)

Unfortunately, you will not find any pair in that range.

Note that when a,b,n are integers, n^2+a*n+b is also an integer.