Given a starting seed (which must be odd), produces a lazy sequence of "random" numbers generated by the infamous RANDU generator, starting with the seed itself.
(ns randu)
(defn randu-seq [x] (iterate #(mod (* 65539 %) 0x80000000) x))
(ns randu-test
(:require [clojure.test :refer :all]
[randu :refer [randu-seq]]))
(deftest test-oeis-a096555
(is
(=
(take 21 (randu-seq 1))
[1 65539 393225 1769499 7077969 26542323
95552217 334432395 1146624417 1722371299
14608041 1766175739 1875647473 1800754131
366148473 1022489195 692115265 1392739779
2127401289 229749723 1559239569]
)
"(randu-seq 1) doesn't match OEIS A096555!"
)
)