n <- as.integer(readline(prompt=“Enter a number:”)) factorial = 1 #set factorial variable to 1

if(n < 0) {print(“factorial does not exist for negative numbers”) } else if(n == 0) { print(“The factorial of 0 is 1”) } else { for(i in 1:n) #for loop to expand n up to 1 { factorial = factorial * i } print(paste(“The factorial of”, n ,“is”,factorial)) }

```
x=20
seq(20, 50, by =5)
```

`## [1] 20 25 30 35 40 45 50`

`class(x)`

`## [1] "numeric"`

```
factorial <- function(a, b, c) {
x1 <- ((-b) + sqrt(b^2 - (4*a*c))/ (2*a))
x2 <- ((-b) - sqrt(b^2 - (4*a*c))/ (2*a))
c(x1, x2)
}
factorial(1, -2, 1)
```

`## [1] 2 2`