Not getting expected output-Paper folding problem

  coding-style, python, python-2.7, python-3.6, python-3.x

Create a function that returns the thickness (in meters) of a piece of paper after folding it n number of times. The paper starts off with a thickness of 0.5mm.

def num_layers(a):
Sum=0
for i in range(-1,100):
    for k in range(1,a+1):
        Sum+=2**i
        if k==a+1:
            break
return (Sum)/1000

Where am I going wrong?I have written it according to the logic but not getting desired result

Source: Python-3x Questions

LEAVE A COMMENT