Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Hailstone-sequence/Transd/hailstone-sequence.transd
Normal file
26
Task/Hailstone-sequence/Transd/hailstone-sequence.transd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#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)
|
||||
)
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue