What if John Conway invented ${FAMOUS_ESOLANG}?

He sort of did:

fractran

It looks like this:

17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1

It works like this:

  • A fractran program is defined as an integer input and a sequence of rational fractions.

  • The program is evaluated as follows:

    1. Find the first fraction f in the series such that n*f is an integer.
    2. If there isn't one, stop. The result is n.
    3. Let n = n*f
    4. Repeat

Conway's prime number generator

For every power of 2 found in the output stream, that power is a prime number:

(defn conway-primes [n]
  (let [prog '(17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1)]
    (take n (filter identity (map power-of-2 (fractran-seq 2 prog))))
))

Hello world!

(For every even number found in the output stream, "print" the exponent of 2.)

  • n = 1220703125
  • program = 7528977498068181366035447808/1220703125 244140625/7528977498068181366035447808 1347363005271780922721618896336453632/244140625 48828125/1347363005271780922721618896336453632 57487488224929319369455739577022021632/48828125 9765625/57487488224929319369455739577022021632 19162496074976439789818579859007340544/9765625 1953125/19162496074976439789818579859007340544 51099989533270506106182879624019574784/1953125 390625/51099989533270506106182879624019574784 115422332637413376/390625 78125/115422332637413376 9393093476352/78125 15625/9393093476352 484503604463601835673437673472185597952/15625 3125/484503604463601835673437673472185597952 630864068311981556866455304000241664/3125 625/630864068311981556866455304000241664 1682304182165284151643880810667311104/625 125/1682304182165284151643880810667311104 8762000948777521623145212555558912/125 25/8762000948777521623145212555558912 11408855402054064613470328848384/25 5/11408855402054064613470328848384 25769803776/5 1/25769803776

Hello world in clojure via fractran:

(defn hello-world []
  (let [n    1220703125
        prog '(7528977498068181366035447808/1220703125 244140625/7528977498068181366035447808 1347363005271780922721618896336453632/244140625 48828125/1347363005271780922721618896336453632 57487488224929319369455739577022021632/48828125 9765625/57487488224929319369455739577022021632 19162496074976439789818579859007340544/9765625 1953125/19162496074976439789818579859007340544 51099989533270506106182879624019574784/1953125 390625/51099989533270506106182879624019574784 115422332637413376/390625 78125/115422332637413376 9393093476352/78125 15625/9393093476352 484503604463601835673437673472185597952/15625 3125/484503604463601835673437673472185597952 630864068311981556866455304000241664/3125 625/630864068311981556866455304000241664 1682304182165284151643880810667311104/625 125/1682304182165284151643880810667311104 8762000948777521623145212555558912/125 25/8762000948777521623145212555558912 11408855402054064613470328848384/25 5/11408855402054064613470328848384 25769803776/5 1/25769803776)
        res (fractran-seq n prog)

        ]
(apply str (map char (filter identity (map #((prime-factors %) 2) res))))
))