+ 1

How could I write a code that sum the power of 2 from 2 ^1 to 2^65?

30th Mar 2016, 1:45 PM
marco colombo
marco colombo - avatar
1 Odpowiedź
+ 3
result = 0 for i in range(66): result += 2 ** i print(result) we define a variable named result by setting it to 0 at start. the i takes values from 0 to 65, so you have the exponentation and the sum of it. hope it helped!
3rd Apr 2016, 3:43 PM
George Tavanidis
George Tavanidis - avatar