id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

konstans@stuy.edu all > sumOfPowers
prev  |  next  |  chance

Write a function to calculate the sum of the powers of two (other than 1) between 0 and n inclusive. sumOfPowers(10) -> 2 + 4 + 8


sumOfPowers(0) → 0
sumOfPowers(10) → 14
sumOfPowers(2) → 2

...Save, Compile, Run (ctrl-enter)

def sumOfPowers(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy