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

bookChallenge: Pure Function Practice

Opgave

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 alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores 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?

close

bookChallenge: Pure Function Practice

Stryg for at vise menuen

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2
single

single

some-alt