-
Notifications
You must be signed in to change notification settings - Fork 0
/
factorablequads
28 lines (19 loc) · 962 Bytes
/
factorablequads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
### Python3
##This will generate factorable quadratics, given whatever values of a,b, and c you would like to constrain the problems to.
Happy factoring!
def isfactorable(a, b, c):
if a * c == d * e and (d + e) == b:
return 1
## If you want to eliminate cases where d and e are equal to a and c
##(Ex: 7x^ + 11x+ 4, d= 7 and e = 4 so it's a little too easy to solve) add this logic into the above function definition:
## "and d !=a and d!=c and e!=a and e!=c: "
#set upper and lower boundaries for a, b, c inside of the range() part of the for loops. Change these however you see fit.
count = 0
for d in range (1,11):
for e in range (1,11):
for a in range(1,11):
for b in range (1,21):
for c in range (1,11):
if isfactorable(a,b,c)==1:
count +=1
print( a, "x^2 + ", b, "x + ", c, " , Count = ", count)