{
  "format": "tokbit",
  "version": 1,
  "name": "Power by recursion",
  "main": [
    {
      "id": "u4",
      "kind": "for",
      "variable": "k",
      "range": "11",
      "body": [
        {
          "id": "u5",
          "kind": "output",
          "values": "\"2 to the\", k, \"=\", power(2, k)"
        }
      ]
    }
  ],
  "functions": [
    {
      "name": "power",
      "params": [
        {
          "name": "b",
          "type": "int"
        },
        {
          "name": "n",
          "type": "int"
        }
      ],
      "returnType": "int",
      "blocks": [
        {
          "id": "u1",
          "kind": "if",
          "condition": "n == 0",
          "then": [
            {
              "id": "u2",
              "kind": "return",
              "value": "1"
            }
          ],
          "else": [
            {
              "id": "u3",
              "kind": "return",
              "value": "b * power(b, n - 1)"
            }
          ]
        }
      ],
      "comment": "Recursion: b to the n is b times b to the (n − 1), and b to the 0 is 1."
    }
  ],
  "comment": "Solution to the task “Power by recursion”: Write a similar function power(b, n) computing bⁿ by recursion: b⁰ = 1, bⁿ = b · bⁿ⁻¹. Print the powers of two up to 2¹⁰."
}
