Python | Polynomial finder (factors of x)

/ 16 Nov 2013 /
Yes, this is great :'), at first it printed all the numbers with what they were equivalent too, but I just made it so it only spits out the ones that equal 0, I'l try to make is so if there's only 2, it will find the third one by looking at (n) and seeing what else could be used to equal (n) by division or something, but that's for another day, adios amigos. (I know it's simple, but it works)



def f(x):
    ans = 2*x**3 - 3*x**2 - 5*x + 6
    if ans == 0:
        print(ans, "=", x)

for x in range(-10, 10):
    f(x)
 
Copyright © 2010 M(ath)+me, All rights reserved