Public Function factor(a, b, c) answerString = "" needNegativeSign = False If a < 0 Then needNegativeSign = True a = a*(-1) b = b*(-1) c = c*(-1) End If product = Abs(a * c) If c = 0 Then n = gcf(Abs(a), Abs(b)) answerString = n & "*x*(" & (a / n) & "*x + " & (b / n) & ")" answerString = Replace(answerString, "+ -", "- ") Else For i = 1 to int(sqr(product)) If product Mod i = 0 Then n1 = i n2 = product / i If c < 0 Then If n1 - n2 = b Then GCF1 = gcf(a, n1) GCF2 = gcf(n2, c) answerString = "(" & GCF1 & "*x - " & GCF2 & ")*(" & (a / GCF1) & "*x + " & (n1 / GCF1) & ")" Exit For ElseIf n2 - n1 = b Then GCF1 = gcf(a, n1) GCF2 = gcf(n2, c) answerString = "(" & GCF1 & "*x + " & GCF2 & ")*(" & (a / GCF1) & "*x - " & (n1 / GCF1) & ")" Exit For End If Else If n1 + n2 = b Or n1 + n2 = -b Then GCF1 = gcf(a, n1) GCF2 = gcf(n2, c) answerString = "(" & GCF1 & "*x + " & GCF2 & ")*(" & (a / GCF1) & "*x + " & (n1 / GCF1) & ")" If n1 + n2 = -b Then answerString = Replace(answerString, "+", "-") End If Exit For End If End If End If Next End If If answerString <> "" Then answerString = replace(answerString, "(-1*", "(") answerString = replace(answerString, "(1*", "(") answerString = replace(answerString, "*", "") If needNegativeSign Then answerString = "-" + answerString End If factor = answerString Else factor = "cannot factor" End If End Function Public Function loanPayment(borrow, rate, years) loanPayment = (borrow*rate/1200)/(1-(1+rate/1200)^(-12*years)) End Function Public Function recurringDeposit(initial, deposit, rate, years) recurringDeposit = initial*(1+rate/1200)^(12*years)+deposit*(1+rate/1200)*((1+rate/1200)^(12*years)-1)/(rate/1200) End Function Public Function solve(a, b, c) disc = b^2 - 4*a*c i = "" If disc < 0 Then i = "i" disc = -disc End If n = int(sqr(disc)) If disc <> 0 Then While (disc mod (n*n) <> 0) n = n -1 Wend disc = disc/(n*n) End If commP1 = GCF(b, 2*a) answer = "" If disc = 1 Then If i = "i" Then commAll = GCF(commP1, n) n1 = -b / commAll * sgn(a) n2 = n / commAll * sgn(a) n3 = (2*a) / commAll * sgn(a) answer = "(" & n1 & " ± " & n2 & "i)/" & n3 & " " answer = Replace(answer, " 1i", " i") answer = Replace(answer, " -1i", " -i") Else n1p = -b + n n1n = -b - n n2p = 2*a n2n = 2*a simpP = GCF(n1p, n2p) simpN = GCF(n1n, n2n) n1p = n1p / simpP * sgn(a) n1n = n1n / simpN * sgn(a) n2p = n2p / simpP * sgn(a) n2n = n2n / simpN * sgn(a) answer = n1p & "/" & n2p & " and " & n1n & "/" & n2n & " " End If ElseIf disc = 0 Then n1 = -b / commP1 * sgn(a) n2 = (2*a) / commP1 * sgn(a) answer = n1 & "/" & n2 & " " Else commAll = GCF(commP1, n) n1 = -b / commAll * sgn(a) n2 = n / commAll * sgn(a) denom = (2*a) / commAll * sgn(a) answer = "(" & n1 & " ± " & n2 & i & "√(" & disc & "))/" & denom & " " answer = Replace(answer, " 1" & i & "√", " " & i & "√") End If answer = Replace(answer, "+ -", "- ") answer = Replace(answer, "/1 ", " ") solve = answer End Function Public Function solveN(a, b, c) solveN = (-b - sqr(b^2 - 4*a*c))/(2*a) End Function Public Function solveP(a, b, c) solveP = (-b + sqr(b^2 - 4*a*c))/(2*a) End Function Public Function vertex(a, b, c) back1 = b^2 - (c * (a * 2)^2) back2 = (a * 2)^2 tempGCF = gcf(back1, back2) back1 = back1/ (-tempGCF) back2 = back2 / tempGCF If back2 < 0 Then back1 = -back1 back2 = -back2 End If tempGCF = gcf(b, a * 2) b1 = b / tempGCF b2 = a * 2 / tempGCF If b2 < 0 Then b1 = -b1 b2 = -b2 End If answerstring = a & "(x + " & b1 & "/" & b2 & ")^2 + " & back1 & "/" & back2 answerstring = Replace(answerstring, "+ -", "- ") answerstring = Replace(answerstring, "/1)", ")") If Right(answerstring, 2) = "/1" Then answerstring = Left(answerstring, Len(answerstring) - 2) If Left(answerstring, 2) = "1(" Then answerstring = Right(answerstring, Len(answerstring) - 1) If Left(answerstring, 3) = "-1(" Then answerstring = "-" & Right(answerstring, Len(answerstring) - 2) vertex = answerstring End Function