Please create the following exercises in .rmd format, publish to rpub and submit both the rmd file and the rpub link
#initialize variables
numFactorial <- 12 # 12!
factorialResult <- 1 # initialize our output as 1 since 0! = 1
#our n! factorial for loop
for( fact in 1:numFactorial )
{
nextFact = fact * factorialResult
factorialResult = nextFact
}
#display our result
cat( '12! = ', factorialResult )
## 12! = 479001600
#using the seq() fxn to specify the range from 20 to 50 in steps of 5
numVec <- seq( from = 20, to = 50, by = 5 )
#display our result
cat( 'numVec: ', numVec )
## numVec: 20 25 30 35 40 45 50
equation. The function should print as output the two solutions.
quadratic <- function( a, b, c )
{
positiveR <- ((-b ) + sqrt( ( b^2 ) - 4*a*c ) )/( 2*a )
negativeR <- ((-b ) - sqrt( ( b^2 ) - 4*a*c ) )/( 2*a )
cat( 'The positive root = ', positiveR, "\n" )
#print( positiveR )
cat( 'The negative root = ', negativeR )
#print( negativeR )
}
#test cases for quadratic:
# moar @ https://www.mesacc.edu/~scotz47781/mat120/notes/quad_formula/quad_formula_practice.html
#quadratic( 1,6,14 )
quadratic( 8,14,-15 )
## The positive root = 0.75
## The negative root = -2.5