Question 1
fct=1
num=12
for (i in 1:num)
{
fct=fct*i
}
print(fct)
## [1] 479001600
Question 2
vect=(seq(20,50,5))
print(vect)
## [1] 20 25 30 35 40 45 50
Question 3 Quadratic Equation Form =ax^2+bx+c
Equation = function(a, b, c) {
if (a == 0){
return ('a cannot be 0')
}
x = (b^2 - 4*a * c)
output1 = (-b + sqrt(x))/(2*a)
output2 = (-b - sqrt(x))/(2*a)
return (c(output1,output2))
}
print(Equation(3,-5,-2))
## [1] 2.0000000 -0.3333333