Use loop to calculate factorial 12

n<-12
res<-1
for(i in 0:11)
{
  res<-res * (n-i)
  
}
print (res)
## [1] 479001600

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

nvec<-c(20:50)
nvc<-nvec[seq(0,length(nvec),5)]
nvc
## [1] 24 29 34 39 44 49

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.

calc_factorial = function(a,b,c){
  sol<-b^2- (4*a*c)
  q<-0
  if(sol<0)
  {
    return ("no solution")
  }
  else{
    q<-q + sqrt(sol)
    
  }
  x1<-(b-q)/(2*a)
  print(x1)
  
  x2<-(b+q)/(2*a)
  print (x2)
  
}
calc_factorial(1,2,1)
## [1] 1
## [1] 1