findfact <- function(x){
factorial <- 1
if ((x==0)|(x==1))
factorial <- 1
else{
for( i in 1:x)
factorial <- factorial * i
}
return (factorial)
}
findfact(12)
## [1] 479001600
seq(from=20, to=50, by=5) -> x
x
## [1] 20 25 30 35 40 45 50
#3. Create the function “quadratic” that takes a trio of input numbers a, b, and #c and solve the quadratic equation. The function should print as output the two #solutions.
#quadratic formula y = ax^2 + bx + c or x = ((-b+-sqrt(b^2-4ac))/2a) #will look into
quad <- function(a, b, c)
{ x1 <- (-(b) + (sqrt(4*a*c))/(2*a))
print(x1)
x2 <- (-(b) - (sqrt(4*a*c))/(2*a))
print(x2) }
quad(a = 1, b = 2, c = 1)
## [1] -1
## [1] -3