Live Quiz Arena
🎁 1 Free Round Daily
⚡ Enter ArenaQuestion
← Logic & PuzzlesA 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.
Related Questions
Browse Logic & Puzzles →- A database query optimizes relation joins using dynamic programming; what happens to memory use as the number of joined tables increases?
- What happens to the computational cost for an attacker when a cryptographic hash function loses its second preimage resistance?
- An automated theorem prover evaluates logical statements in a circuit design. Which outcome definitively indicates that a propositional formula is a tautology?
- A digital circuit design, represented as a CNF formula, contains a clause (A ∨ ¬A). If using a SAT solver, which consequence follows?
- A municipal water distribution system experiences fluctuating demand; which effect results when the system of linear equations representing water flow and pressure at each node becomes underdetermined?
- In programmable logic controllers (PLCs), if a sensor's boolean output indicates 'NOT (A AND B)', which equivalent expression allows simplified ladder logic implementation?
