#Question 1

factorial <- 1
for (n in 1:12){
  factorial <- factorial * n
}

print(factorial)
## [1] 479001600
sprintf('The roots of %.0fx^2 + %.0fx + %.0f are:', 1, 1, 1)
## [1] "The roots of 1x^2 + 1x + 1 are:"

#Question 2

num_vec <- as.numeric(5*(4:10))
print(num_vec)
## [1] 20 25 30 35 40 45 50

#Question 3

quad <- function(a, b, c){
  if (is.numeric(a) & is.numeric(b) & is.numeric(c)) {
    #define discriminant
    discriminant <- b^2 - 4 * a * c
    sqrt_num <- 0
    
    #if root is complex
    if (discriminant < 0){
      sqrt_num <- sqrt(as.complex(discriminant))/2
      
    #root is real
    }
    else{
      sqrt_num <- sqrt(discriminant)
    }

    x1 <- (-b + sqrt_num)/2
    x2 <- (-b - sqrt_num)/2
    
    print(x1)
    print(x2)
  }
}

quad(1, 6, 5)
## [1] -1
## [1] -5