Elina Azrilyan - Homework 1

  1. Write a loop that calculates 12-factorial
nvect <- c(1:12)
y <- prod(nvect)
y
## [1] 479001600
  1. Show how to create a numeric vector that contains the sequence from 20 to 50 by 5.
c<- seq(20, 50, 5)
c
## [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.
FactiorialFunction <- function(a,b,c) {
    x1 <- (-b+((b^2)-4*a*c)^0.5)/(2*a)
    x2 <- (-b-((b^2)-4*a*c)^0.5)/(2*a)
    
    answersx1andx2 <- c(x1,x2)
    answersx1andx2
}
FactiorialFunction(4,53,2)
## [1]  -0.03784394 -13.21215606