Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Pure Function Practice | Pure vs Impure Functions & Stepwise Decomposition
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Methods & Modular Thinking

bookChallenge: Pure Function Practice

Uppgift

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 ArgumentException if the input is negative.
  • Ensure the method does not read from or modify any external state.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 2
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: Pure Function Practice

Svep för att visa menyn

Uppgift

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 ArgumentException if the input is negative.
  • Ensure the method does not read from or modify any external state.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 2
single

single

some-alt