a1 = -3
b1 = 5
c1 = 10
factorial <- function (a,b,c){
dtm <- (b^2 - 4*a*c)
if (dtm>0) {
dtm <- sqrt(dtm)
soln1 <- (-1*b + dtm)/(2*a)
soln2 <- (-1*b - dtm)/(2*a)
soln <- c(soln1, soln2)
}
return (ifelse (dtm > 0, list(soln), "No Solution"))
}
x <- factorial(a1,b1,c1)
print (x)
## [[1]]
## [1] -1.173599 2.840266
The solution to the equation -3x^2 + 5x + 10 = 0 is c(-1.17359909646538, 2.84026576313205).