top of page

PROGRAMMING CHALLENGES

Recursive Factorial to Iterative

Difficulty:

2 Medium

2.5 Recursion

Topic:

Given the following pseudocode for calculating a factorial using recursion, rewrite it to use an iterative approach.

Remember that recursion involves a function calling itself, while iteration involves loops like for or while loops.

FUNCTION factorial(n)
IF n == 1
RETURN 1
ELSE
RETURN n * factorial(n - 1)

ENDFUNCTION

Need help with your programming skills?

If you need more help than just independent practise, then we're here for you. Book a 1:1 with us and we will be able to guide you to becoming a proficient programmer who can tackle any of the challenges an exam board can throw at you.

bottom of page