MSDS BRIDGE R WEEK 1 HOME WORK / YOHANNES DEBOCH output: html_document —
# Declare res
res <- 1
for(i in 1:12){
# Do multiplication
res <- res*i
}
# Print the result
print(res)
## [1] 479001600
# Create a numeric vector
num.vec <- seq(20,50,5)
num.vec
## [1] 20 25 30 35 40 45 50
# Crating functions
factorial <- function(a, b, c){
# Find the solution
sol1 <- (-b+sqrt(b^2-4*a*c))/(2*a)
sol2 <- (-b-sqrt(b^2-4*a*c))/(2*a)
# Print solution
print(sol1)
print(sol2)
}
# Test the functions
factorial(1, 3, -4)
## [1] 1
## [1] -4