Explanation of the math and more visualizations at the Mathologer (YouTube).
More solutions in TypeScript, PureScript, and Elm.