EasyNo. 2803LeetCode Premium
Factorial Generator — LeetCode 2803 Python Solution
- Topics
- JavaScript
- Reading time
- 2 min
- Source
- leetcode.com
The problem
Write a generator function that takes an integer n as an argument and returns a generator object which yields the factorial sequence. The factorial sequence is defined by the relation n!
Example
- Input
- n = 5
- Output
- [1,2,6,24,120]
- Explanation
- const gen = factorial(5)
Complexity
- Time
- O(n)
- Space · auxiliary
- O(1) to O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 2798 | Number of Employees Who Met the Target | Easy |
| 0057 | Insert Interval | Medium |
| 0192 | Word Frequency | Medium |
| 0193 | Valid Phone Numbers | Easy |
| 0194 | Transpose File | Medium |
| 0195 | Tenth Line | Easy |
Frequently asked questions
- How hard is LeetCode 2803. Factorial Generator?
LeetCode 2803. Factorial Generator is rated Easy on LeetCode.
- What topics does LeetCode 2803. Factorial Generator cover?
LeetCode 2803. Factorial Generator is tagged JavaScript on LeetCode.
- Is LeetCode 2803. Factorial Generator a premium problem?
Yes. LeetCode 2803. Factorial Generator is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.