Post History
Sandbox
Obligatory factorial challenge
#4: Post edited
- It looks like we don't have a simple factorial challenge yet, so here's one.
- # Task
- Given a non-negative number, output the factorial of that number ($n!$). The factorial of a number can be defined as such:
- $$f(0)=1$$
- $$f(n)=n \times f(n-1)$$
- # Test cases
- ```
- Input! = Output
- 0! = 1
- 1! = 1
- 2! = 2
- 3! = 6
- 4! = 24
- 5! = 120
- 6! = 720
- 10! = 3628800
- ```
- # Rules
- - The [default rules](https://codegolf.codidact.com/posts/282784) for input and output apply.
- This is [code-golf], so the shortest code in bytes wins!
- It looks like we don't have a simple factorial challenge yet, so here's one.
- # Task
- Given a non-negative number, output the factorial of that number ($n!$). The factorial of a number can be defined as such:
- $$f(0)=1$$
- $$f(n)=n \times f(n-1)$$
- # Test cases
- ```
- Input! = Output
- 0! = 1
- 1! = 1
- 2! = 2
- 3! = 6
- 4! = 24
- 5! = 120
- 6! = 720
- 10! = 3628800
- ```
- # Rules
- - The [default rules](https://codegolf.codidact.com/posts/282784) for input and output apply.
- - This is [code-golf], so the shortest code in bytes wins!
- - Should I delete this draft or put it on hold? Razetime has pointed out that we don't want too many challenges similar to those Somewhere Else, but I thought this'd be a good challenge for beginners.
#1: Initial revision
Obligatory factorial challenge
It looks like we don't have a simple factorial challenge yet, so here's one. # Task Given a non-negative number, output the factorial of that number ($n!$). The factorial of a number can be defined as such: $$f(0)=1$$ $$f(n)=n \times f(n-1)$$ # Test cases ``` Input! = Output 0! = 1 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 10! = 3628800 ``` # Rules - The [default rules](https://codegolf.codidact.com/posts/282784) for input and output apply. - This is [code-golf], so the shortest code in bytes wins!