1. Write a loop that calculates 12-factorial:

val = 1
for (i in 1:12) {
  val <- sum(i * val)
}
sprintf("12! = %f", val) 
## [1] "12! = 479001600.000000"

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

num_vect <- seq(from = 20, to= 50, by= 5)

class(num_vect) #display data type to ensure it is numeric
## [1] "numeric"
num_vect #to display answer
## [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 <- function(a, b, c){
  if (a == 0){
    return("a can't be zero!")
  }
  neg_b <- -b
  square_root <- sqrt(b^2 - 4* a * c)
  two_a <- 2 * a
  
  answer_one <- (neg_b + square_root)/two_a
  answer_two <- (neg_b - square_root)/two_a
  
  sprintf("The first answer is: %f and the second answer is: %f", answer_one, answer_two)
  #sprintf(" ", answer_two)
  #print(answer_two)
}

quadratic(5,-5,-2)
## [1] "The first answer is: 1.306226 and the second answer is: -0.306226"