##Maryluz Cruz ##7/21/2019

###HW # 1

##1.Write a loop that calculates 12-factorial

factor = 1 for(i in 12:1) { factor = factor*i } print(paste0(“The factorial of 12 is:”, factor))

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

seq(from = 20, to = 50, by = 5)

##3.Create the function “factorial” that takes a trio of input numbers a, b, c and solve the quadratic equation. The function print as output the two solutions.

factorial <-function(a, b, c) { sol1=(-b+(b^2 - 4ac)^(1/2))/(2a) sol2=(-b-(b^2 - 4ac)^(1/2))/(2a) print (paste0(“Solution Number 1 is”, sol1)) print(paste0(“Solution Number 2 is”, sol2)) print(paste0(“If Solution is NaN then solutions are complex”)) } factorial(6, 15, 5)

factorial(4,6,2)

factorial(5,6,15)

factorial(2,8,4)