Post

Kode Gurukul
Kode Gurukul@kodegurukul·
Here we are simply calculating the factorial of the number using recursion. Let's see the breakdown of the recursion(iteration wise): 1⃣. 5 * factorial(4) 2⃣. 5 * 4 * factorial(3) 3⃣. 5 * 4 * 3 * factorial(2) 4⃣. 5 * 4 * 3 * 2 * factorial(1) 5⃣. 5 * 4 * 3 * 2 * 1 * factorial(0) 6⃣. 5 * 4 * 3 * 2 * 1 * 1 # base case reached, factorial(0) is 1 Answer= 120
Kode Gurukul tweet media
English
0
0
0
633
tech tweets
tech tweets@techtweet786·
@Python_Dv 120 The factorial function is a recursive function that calculates the factorial of a given number n. The base case is if n == 0, where it returns 1. Otherwise, it recursively calls itself with n-1 and multiplies the result by n.
English
0
0
0
5
Luz
Luz@Luz_opinando·
@Python_Dv c) 120 It calculates recursively 5*factorial(4) and so on till it reaches factorial(0) that ends the sequence.
English
0
0
0
295
Paylaş