#lang transd MainModule: { primes: Vector([3, 5]), lim: 200, bigUn: 100000, chunks: 50, little: 0, c: 0, showEach: true, u: ULong(0), v: ULong(1), _start: (λ found Bool() fnd Bool() mx Int() z ULong() (= little (/ bigUn chunks)) (for i in Range(1 (pow 2 20)) do (= found false) (+= u 6) (+= v u) (= mx (to-Int (sqrt v) 1)) (for item in primes do (if (> item mx) break) (if (not (mod v item)) (= found true) break)) (if (not found) (+= c 1) (if showEach (= z (get primes -1)) (while (< z (- v 2)) (+= z 2) (= fnd false) (for item in primes do (if (> item mx) break) (if (not (mod z item)) (= fnd true) break)) (if (not fnd) (append primes z))) (append primes v) (textout :width 11 :group v) (if (not (mod c 10)) (textout :nl)) (if (== c lim) (= showEach false) (textout "Progress to the " :group bigUn "'th cuban prime:" )) ) (if (not (mod c little)) (textout ".")) (if (== c bigUn) break) ) ) (lout "The " :group c "'th cuban prime is " v ) ) }