12. Recursive sequence
Last updated
Was this helpful?
Last updated
Was this helpful?
The problem can be found at the following link:
This question is straightforward. Simply follow the steps asked by the question. I used two loops to compute the partial factorial, then combined sequence using modular arithmetic.
Time Complexity: (O(n^2))
- The nested loops iterate through each integer up to n, and within each iteration, there is a calculation of the factorial which takes (O(n))
time.
Auxiliary Space Complexity: (O(1))
- Only a few variables are used for calculations, independent of the input size.
For discussions, questions, or doubts related to this solution, please visit our . We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star
to the repository.