#1. Write a loop that calculates 12-factorial.
#2. Show how to create a numeric vector that contains the sequence from 20 to 50 by 5.
#3. 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.
############ Answer 1 #####################
factorial_rec <- function(x){
  y =1
  for (i in c(1:x)){
      y <- y*i
  }
  return (y)
}

print(factorial_rec(12))
## [1] 479001600
y <- seq(20,50,5)
y
## [1] 20 25 30 35 40 45 50
fact <- function(a, b, c) {
  r <- b ^ 2 - 4 * a * c
  if (r >= 0){
    ans1 = (-b + sqrt(r))/(2 * a)
    ans2 = (-b - sqrt(r))/(2 * a)
    return(c(ans1, ans2))
    }
  
}
print(fact(1,-1,0))
## [1] 1 0
print(fact(1,1,0))
## [1]  0 -1