Skip to main content
Version: 1.17

Chapter 2

Once Zee arrived to Pamplona, a mystical creature appeared: Lerna's Hydra. 🐍 The Hydra was a one-headed monster that when it's head was cut off, 2 more heads would grew in its place.

Zee reached for a sword 🗡️ and cut off the head of the beast. As a result 2 more appeared. 😱 Zee cut both heads off again, which doubled to 4. How many heads would the beast have after cutting them for 5 times?

We could try to represent this in a multiplication like this: 2*2*2*2*2, but we can leverage exponentiation and represent it like the following expression:

Expression

// use exponentiation to represent the multiplications
2*2*2*2*2

Context

A JSON document that is used to resolve variables in the expression.
{
  "base": 2,
  "exponent": 5
}


Result

<click 'Evaluate' to see the result of the expression>

Warnings

<none>
Solution
By the 5th time, there were 32 heads and no apparent way out, thankfully the heads started fighting with each other and Zee was able to escape.

Expression
base ** exponent