You need to sign in or sign up before continuing.×
Ad
Mathematics
  • Challenge: Write a function that takes an integer as input (number of candles on a birthday cake) and returns the number of ways the candles can be lit.

  • Explanation: A birthday cake with n candles can have 2^n different lighting combinations (all candles lit, none lit, some lit, etc.).

  • Example Test Cases:

birthdayCandles(2) => 4

birthdayCandles(4) => 16

def birthday_candles(candles):
    return 2 ** candles