...
/Solution: Nested Loop With Multiplication (Intermediate)
Solution: Nested Loop With Multiplication (Intermediate)
This review provides a detailed analysis of the different ways to solve the Nested Loop with Multiplication in an advanced problem.
We'll cover the following...
Solution #
Press + to interact
n = 10 # can be anything, this is just an examplesum = 0pie = 3.14for var in range(1, n, 3):j = 1print(pie)while j < n:sum += 1j *= 3print(sum) # O(1)
-
Outer Loop:
-
Inner Loop: ...
Statement | Number of Executions |
---|---|
n = 10 | 1 |
sum = 0 | 1 |
pie = 3.14 | 1 |
for var in range(1,n,3): |