Solution: Nested Loop With Multiplication (Advanced)
This review provides a detailed analysis of the different ways to solve the nested loop with multiplication challenge.
We'll cover the following...
Solution #
Press + to interact
n = 10 # can be anythingsum = 0pie = 3.14for var in range(n):j = 1while j < var:sum += 1j *= 2print(sum)
In the main function, the outer loop is as it iterates over n
. The inner while loop iterates over i
which is always less than n
and j
is doubled each time, therefore we can say that it is ...
Access this course and 1400+ top-rated courses and projects.