This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
#Problem 1
factorial <- 1
for (i in 1:12){
factorial = factorial * i
}
print(factorial)
## [1] 479001600
#Problem 2
v <- vector(mode="numeric", length=0L)
for(i in seq(from=20, to=50, by=5)){
v <- c(v, i)
}
print(v)
## [1] 20 25 30 35 40 45 50
#Problem 3
quadratic <- function(a,b,c){
if (a == 0){
print("Error, cannot divide by 0")
}
else{
x1 = (-b + sqrt((b^2)-(4*a*c)))/(2*a)
x2 = (-b - sqrt((b^2)-(4*a*c)))/(2*a)
print(x1)
print(x2)
}
}