27 lines
721 B
Plaintext
27 lines
721 B
Plaintext
#lang transd
|
|
|
|
MainModule: {
|
|
hailstone: (λ n Int()
|
|
(with seq Vector<Int>([n])
|
|
(while (> n 1)
|
|
(= n (if (mod n 2) (+ (* 3 n) 1)
|
|
else (/ n 2)))
|
|
(append seq n)
|
|
)
|
|
(ret seq)
|
|
)
|
|
),
|
|
|
|
_start: (λ
|
|
(with h (hailstone 27) l 0 n 0 t 0
|
|
(lout "Length of (27): " (size h))
|
|
(lout "First 4 of (27): " Range(in: h 0 4))
|
|
(lout "Last 4 of (27): " Range(in: h -4 -0))
|
|
(for i in Range(100000) do
|
|
(= t (size (hailstone (to-Int i)))) (if (> t l) (= l t) (= n i))
|
|
)
|
|
(lout "For n < 100.000 the max. sequence length is " l " for " n)
|
|
)
|
|
)
|
|
}
|