factorial = 1
for(i in 1:12) {
factorial = factorial * i
}
factorial
## [1] 479001600
The factorial of 12 is 4.79001610^{8}
A vector from 20-50 increaseing by one can be accomplished by the flollowing code:
vec = seq(from = 20, to = 50, by = 5)
The vector is 20, 25, 30, 35, 40, 45, 50
Create a fucntion that that takes a trio of numbers and solves the quadratic equation:
func = function(a,b,c){
if(b**2 <= 4 * a * c){
print('This cannot be calculated')
}
else{
x = (-b + sqrt(b^2 - 4*a*c))/(2*a)
y = (-b - sqrt(b^2 - 4*a*c))/(2*a)
#return(x)
print(x)
print(y)
}
}
func(1,5,2)
## [1] -0.4384472
## [1] -4.561553