Calculating n!
Exercise Type: Implementation
Instructions
The factorial of a natural number (n!) is defined as such:
0! = 1
1! = 1
2! = 1 * 2
3! = 1 * 2 * 3
n! = 1 * 2 * 3 * ... * n
Part 1 - backbone
Write a bit of code using a while()
loop to calculate n!! Calculate 12!
Part 2 - function
Make the code you produced in Part 1 a function that has the following characteristics:
name: | Fact() |
argument(s): | n (numeric) |
return | numeric , the factorial of n |
Part 3 - defense
Make a list of cases when the function has no meaning. Make sure that the function returns missing values when this is the case!