...

/

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 example
sum = 0
pie = 3.14
for var in range(1, n, 3):
j = 1
print(pie)
while j < n:
sum += 1
j *= 3
print(sum) # O(1)
  • Outer Loop: 1+4+7+10++n=n31+4+7+10+\cdots+n = \frac{n}{3} ...

Access this course and 1400+ top-rated courses and projects.