VibraXX
Live Quiz Arena
🎁 1 Free Round Daily
⚡ Enter Arena
HomeCategoriesLogic & PuzzlesQuestion
Question
Logic & Puzzles

A recursive function calculates the factorial of a number; if a user accidentally provides a negative input, which outcome is most likely?

A)The function returns zero immediately
B)The function enters infinite recursion
C)The function returns one immediately
D)The program halts with no output

💡 Explanation

The function enters infinite recursion because a negative input won't satisfy the base case, and the recursion continues indefinitely via the decrementing step; therefore, the function won't terminate, rather than halting or returning a default value.

🏆 Up to £1,000 monthly prize pool

Ready for the live challenge? Join the next global round now.
*Terms apply. Skill-based competition.

⚡ Enter Arena

Related Questions

Browse Logic & Puzzles