1. Write a loop that calculates 12-factorial:

my_fact <- 1 #defining vector

#loops to 12
for (x in 1:12) {
  my_fact <- my_fact * x
  cat(x, "!: ", my_fact, "\n")
}
## 1 !:  1 
## 2 !:  2 
## 3 !:  6 
## 4 !:  24 
## 5 !:  120 
## 6 !:  720 
## 7 !:  5040 
## 8 !:  40320 
## 9 !:  362880 
## 10 !:  3628800 
## 11 !:  39916800 
## 12 !:  479001600

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

numeric_seq <- as.numeric(seq(20,50, by =5))
numeric_seq
## [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){
  
  inner <- (b^2) - 4 * a * c
  
  if(inner > 0){
    ans1 <- (-b + sqrt(inner))/(2*a)
    ans2 <- (-b - sqrt(inner))/(2*a)
    x <- c(ans1,ans2)
    return(x)
  } else if (inner == 0) {
    x <- -b/(2*a)
    return(x)
  }
}
quadratic(5,-7,-3)
## [1]  1.7440307 -0.3440307