Load the dplyr packages.
library(dplyr)
Calculate 12-factorial
factorial = 1
for(i in 1:12) {
factorial = factorial * i}
print(paste("The factorial of", "12" ,"is",factorial))
## [1] "The factorial of 12 is 479001600"
Create a numeric vector that contains the sequence from 20 to 50 by 5
NV <- seq(20, 50, 5)
NV
## [1] 20 25 30 35 40 45 50
Solve Quadratic Equation ax2+bx+c=0
#Calculation
a<-2
b<-4
c<--4
result1<-(-b-sqrt((b^2)-4*a*c))/(2*a)
result2<-(-b+sqrt((b^2)-4*a*c))/(2*a)
cat('result 1: ', result1)
## result 1: -2.732051
cat('result 2: ', result2)
## result 2: 0.7320508