Challenge: Pure Function Practice
Task
Swipe to start coding
Write a method that calculates the factorial of a given integer in a pure manner. The function must not cause any side effects and should only depend on its input.
- Return the correct factorial value for non-negative integer input.
- Throw an
ArgumentExceptionif the input is negative. - Ensure the method does not read from or modify any external state.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Awesome!
Completion rate improved to 8.33
Challenge: Pure Function Practice
Swipe to show menu
Task
Swipe to start coding
Write a method that calculates the factorial of a given integer in a pure manner. The function must not cause any side effects and should only depend on its input.
- Return the correct factorial value for non-negative integer input.
- Throw an
ArgumentExceptionif the input is negative. - Ensure the method does not read from or modify any external state.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 2
single