I'm trying to write a program that will factor any trinomial of the form ax^2+bx+c, but I'm kind of stuck. I've got a sequence of 4 for loops that looks like this:
print "Factoring...\n" for i in range(low_value, high_value): for j in range(low_value, high_value): for k in range(low_value, high_value): for l in range(low_value, high_value): print "testing\n" if i*k==a & j*l==c & (i*l)+(j*k)==b: print "Your factored Equation is: (" + i + "x + " + j + ")(" + k + "x + " + l + ")" else: print "No solution found.\n" print "testing...\n" Anyways I know the code is far from optimal but nothing inside the for loops are executing. The "testing..." message at the end is displayed but nothing is printed before that(by that I mean the "testing", "Your factored equation is:", or the "No solution found"). Is there some kind of limitation in Python where I can't use so many for loops at once? Is there something wrong with my syntax that I just am unable to see? Any help would be greatly appreciated :)
low_valueandhigh_value?print "testing", so there doesn't seem to be any problem with the loops.andkeyword in place of&in yourifstatement.