1. Write a loop that calculates 12-factorial
s <- 1
for (i in 1:12) {  
  s <- s * i   
}  

2. Show how to create a numeric vector that contains the sequence from 20 to 50 by 5.
#Initialize an empty vector
v <- c()  
for (i in 20:50) {
  # if i is divisible by 5 then add to the vector
  if (i %% 5 == 0) {
    v <- append(v,i)
  }
}

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.
solve.quadratic <-function (a=1, b=-5, c=6) {
  # Validate the inputs by checking if we'll encounter an imaginary number
  if ( (b * b -4 * a * c) < 0 ) {
    print( "There are no roots" )
    return()
  }
  
  # Use the quadratic equation to find the roots
  root1 <- (-b + sqrt( (b * b) - 4 * a * c)) / (2*a)
  root2 <- (-b - sqrt( (b * b) - 4 * a * c)) / (2*a)

  # Test if there is a decimal before printing
  if ( root1 %% 1 == 0 ) {
    print (sprintf ("x = [%d,%d]", root1, root2))
  } else {
    print (sprintf ("x = [%f,%f]", root1, root2))
  }
  
}