🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Recursion & Backtracking Quiz: all 7 questions

Recursion & Backtracking Quiz · Question 2 of 7

What does this print? (code)

What does this print?

def f(n):
    if n <= 1:
        return 1
    return n * f(n - 1)
print(f(5))
Answer & explanation

Correct answer: 120

5 × 4 × 3 × 2 × 1 = 120.

Can you get the rest right without peeking?

Take the timed Recursion & Backtracking Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →