https://github.com/olical/collatz
Collatz conjecture computation with snazzy rendering.
https://github.com/olical/collatz
clojure collatz collatz-conjecture quill
Last synced: 4 months ago
JSON representation
Collatz conjecture computation with snazzy rendering.
- Host: GitHub
- URL: https://github.com/olical/collatz
- Owner: Olical
- License: epl-1.0
- Created: 2017-03-30T22:03:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T21:06:04.000Z (about 8 years ago)
- Last Synced: 2025-01-05T02:10:36.339Z (5 months ago)
- Topics: clojure, collatz, collatz-conjecture, quill
- Language: Clojure
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# collatz
The [Collatz conjecture][wiki] in Clojure as a lazy sequence. Also includes a neat visualisation inspired by [this awesome video][numberphile], you can run the visualisation with `lein run`.
Nothing will render until you hit the `Enter` key, and even then it may take a little while, it's fairly CPU intensive.
> Visualisation is still completely wrong right now, it still looks kind of neat, but it's not the final product.
You'll find the actual Collatz sequence function in the `collatz.core` namespace.
```clojure
(ns cool.thing
(:require [collatz.core :as c]))(first (c/collatz 1000)) ;; Returns 1000, the seq starts where you specify and counts down.
(last (c/collatz 1000)) ;; Returns 1, as it always will be, I assume?
```If the last value is ever not 1, notify your closest mathematician and run.
[wiki]: https://en.wikipedia.org/wiki/Collatz_conjecture
[numberphile]: https://www.youtube.com/watch?v=LqKpkdRRLZw