I am writing a function to find all the rational zeros of a polynomial and in need to divide each number in a list by each number in a list Ex.
list1 = [1,2,3,4,5,6,10,12,15,20,30,60]
list2 = [1,2,3,6]
zeros = [1/1,2/1,3/1,4/1,...,1/2,2/2,3/2,4/2,...1/3,2/3,3/3,4/3,etc...]
How would I accomplish this? Edit: Here is my code:
from fractions import Fraction
def factor(x):
x = abs(x)
factors = []
new_factors = []
for n in range(1,x):
if x % n == 0:
factors.append(n)
new_factors.append(n)
for y in factors:
new_factors.append(y * -1)
new_factors = sorted(new_factors)
return new_factors
print(factor(8))
def find_zeros(fnctn,pwr):
last = fnctn[len(fnctn)]
first = fnctn[0]
P_s = factor(last)
Q_s = factor(first)
p_zeros = []
Would I do something like this:
for x in P_s:
for y in Q_s:
p_zeros.append(x/y)