Answer:
> factorial()
Input a number to find factorial : 50
[1] " The factorial result is 50 is 3.04140932017134e+64"
> factorial()
Input a number to find factorial : 48
[1] " The factorial result is 48 is 1.24139155925361e+61"
and we divide both numbers and we got 2450
Explanation:
We know that in permutations the order matters, and the general formula for
is given by:
![nPx = (n!)/((n-x)!)](https://img.qammunity.org/2021/formulas/mathematics/high-school/nj75bkqqvimnqg9zqtw2mela6prg87t4if.png)
So we need to create a function for the factorial function in R like this:
factorial <- function(){
# The function only accepts an integer
number = as.integer( readline(" Input a number to find factorial : "))
fact = 1
# If the number is negative or 0
if(number < 0) {
print(" The number is negative the factorial does not exist. ")
} else if(number == 0) {
print(" The factorial result is 1 ")
} else {
for( i in 1:number) {
fact = fact * i
}
print(paste(" The factorial result is ", number ,"is", fact ))
}
}
And we can find the expression like this:
> factorial()
Input a number to find factorial : 50
[1] " The factorial result is 50 is 3.04140932017134e+64"
> factorial()
Input a number to find factorial : 48
[1] " The factorial result is 48 is 1.24139155925361e+61"
and we divide both numbers and we got 2450