factorial = 1
for (n in 1:12){
if(n == 1) factorial= 1
else {
factorial <- factorial * n
}
cat(n, "!:", factorial, "\n")
}
vector <- c(seq.int(20, 50, by = 5))
vector
quadratic <- function(a, b, c) {
Sqrtnum <- b^2 - 4*a*c
if(Sqrtnum > 0) {
x1 <- (-b+sqrt(b^2 - 4*a*c))/(2*a)
x2 <- (-b-sqrt(b^2 - 4*a*c))/(2*a)
x3 <- c(x1, x2)
x3
} else if (Sqrtnum == 0) {
x3 <- -b/(2*a)
x3
} else {"the number under square root is zero or less."}
}
quadratic(5, -3, -2)
quadratic(6, 9, 4)