Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Post History

71%
+3 −0
Sandbox Obligatory factorial challenge

posted 3y ago by user‭  ·  edited 3y ago by user‭

#4: Post edited by user avatar user‭ · 2021-08-07T18:17:37Z (over 3 years ago)
  • 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.
#3: Post edited by user avatar user‭ · 2021-08-06T13:45:35Z (over 3 years ago)
#2: Post edited by user avatar user‭ · 2021-08-06T13:45:01Z (over 3 years ago)
#1: Initial revision by user avatar user‭ · 2021-08-06T13:44:39Z (over 3 years ago)
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!