# I'm a loop that calculates 12-factorial
factorial_loop <- function(x) {
if(x == 0) {
return(1)
} else {
return(x * factorial_loop(x-1))
}
}
factorial_loop(12)
## [1] 479001600
# I make a numeric vector that increments by units of 5 from 20 through 50
numeric_vector <- seq(20, 50, 5)
numeric_vector
## [1] 20 25 30 35 40 45 50
# I create a function "factorial" that takes a, b, c to solve a quadratic (when the discriminant ain't 0, for simplicity's sake)
factorial <- function(a, b, c) {
pos_result <- (b+sqrt(b^2-4*a*c))/(2*a)
neg_result <- (-b+sqrt(b^2-4*a*c))/(2*a)
print(pos_result)
print(neg_result)
}