Exercise 83
Write an algorithm in python that computes a factorial of an integer recursively without using the for loop.
Solution
def facto(n):
if n == 0:
return 1
else:
return n*facto(n-1)
# testing algorithm:
print("Factorial of 5 is : 5! = ", facto(5))
Younes Derfoufi
my-courses.net
my-courses.net