Big O
)}

Problem

This function takes a number and calculates its factorial using recursion.

def factorial(n): if n == 0: return 1 else: return n * factorial(n-1)

Solution

Input SizeRecursions
11
22
33
44
55

How does the running time increase w.r.t the input?

The number of recursions is determined by the size of the input: NN.

What is the time complexity?

O(N)O(N)


This workbook was created by Jad and Rayan Slim. Feel free to explore some of their courses:
The Complete Java Development Bootcamp
The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
0.0
0 students
5

0%
4

0%
3

0%
2

0%
1

0%
Written Reviews
There are no written reviews yet.