Problem 1

factorial <- function(x)
{
    if (x == 0) return(1)
   else
       return(x * factorial(x-1))
}
factorial(6)
## [1] 720

Problem 2

seq(20, 50, by=5)
## [1] 20 25 30 35 40 45 50

Problem 3

quadratic = function(a, b, c) 
{
    x = b^2 - 4 * a * c
    if (x < 0) 
    {
        warning("This has complex roots ")
        x = as.complex(x)
    }
    d = sqrt(x)
    z = (-b + c(-1, 1) * d)/(2 * a)
    return(z)
}
quadratic(3, 7, 2)
## [1] -2.0000000 -0.3333333