Question1: Write a loop that calculates 12-factorial

calcFactorial <- function(num)
{
  fact <- 1
  for (i in num:1)
  {
    fact <- fact * i
    i <- i - 1
  }
  return(fact)
}

calcFactorial(12)
## [1] 479001600

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

numSeq <- seq(20, 50, by = 5)
numSeq
## [1] 20 25 30 35 40 45 50

Question3: 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.

solve.Quadratic <- function (a,b,c)
{
  coeff <- sqrt(b*b - 4*a*c)
  x1 <- (-b + coeff)/(2*a)
  x2 <- (-b - coeff)/(2*a)
  
  soln <- c(x1,x2)
  return (soln)
}

qdrSoln <- solve.Quadratic(a = 4,b = 10,c = 6)
print(qdrSoln)
## [1] -1.0 -1.5