Write a loop that calculates 12 factorial

factorial <- function(x){
y <- 1
for(i in 1:x) {
y <-y *((1:x) [i] )
print (y)
}
}

factorial(12)

[1] 1
[1] 2
[1] 6
[1] 24
[1] 120
[1] 720
[1] 5040
[1] 40320
[1] 362880
[1] 3628800
[1] 39916800
[1] 479001600

Show how to create a numeric vector that contains the sequence from 20 to 50 by 5

numVec <- seq(20, 50, by = 5)
is.vector(numVec, mode = “numeric”)

[1] TRUE

Create the function “factorial”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

factfun <- function(a, b, c) {
numSqrt <- b^2 - 13ac
if(numSqrt > 0) {
x1 <- (-b+sqrt(b^2 - 13ac))/(2a)
x2 <- (-b-sqrt(b^2 - 13
ac))/(2a)
x <- c(x1, x2)
x
} else if (numSqrt == 0) {
x <- -b/(2*a)
x
} else {“No results when the number under square root less than 0.”}
}

factfun(1, 2, -15)

[1] 6.053368 -8.053368