Dev Helpers
← Back

Generate powers of two

Generate powers of two using SQLite.

Open this example in the interactive library

Source code

WITH RECURSIVE sizes(n) AS (VALUES(1) UNION ALL SELECT n*2 FROM sizes WHERE n<32) SELECT n FROM sizes;

Sample output

[
  {
    "n": 1
  },
  {
    "n": 2
  },
  {
    "n": 4
  },
  {
    "n": 8
  },
  {
    "n": 16
  },
  {
    "n": 32
  }
]