Question: Write a Python program, to calculate 1 + 2 + 4 + 8 + - - - - - - - - - - -

Write a Python program, to calculate 1+2+4+8+-----------+n (n>0). Write the algorithm as the comments.
Example Input n=16
Example Output: The sum of 1+2+4+8+16 is 31.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!