1. Write a loop that calculates 12-factorial
for(i in 12:1) {
  if(i == 12) {
    j <- i
    next
  }
  
  j <- j*i
  
  if(i == 1) {
    print(j)
  }
}
## [1] 479001600

  1. Show how to create a numeric vector that contains the sequence from 20 to 50 by 5.
x <- seq(20, 50, by = 5)
x
## [1] 20 25 30 35 40 45 50

or alternately

a <- 20:50
b <- (a %% 5) == 0
a[b]
## [1] 20 25 30 35 40 45 50

  1. 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.
factorial <- function(a, b, c){
  x <- (-b + sqrt(b^2 - 4*a*c)) / 2*a
  y <- (-b - sqrt(b^2 - 4*a*c)) / 2*a
  
  solutions <- c(Solution1 = x, Solution2 = y)
  print(solutions)
}

factorial(1, 5, 0)
## Solution1 Solution2 
##         0        -5