Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Hailstone-sequence/ACL2/hailstone-sequence.acl2
Normal file
16
Task/Hailstone-sequence/ACL2/hailstone-sequence.acl2
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
(defun hailstone (len)
|
||||
(loop for x = len
|
||||
then (if (evenp x)
|
||||
(/ x 2)
|
||||
(+ 1 (* 3 x)))
|
||||
collect x until (= x 1)))
|
||||
|
||||
;; Must be tail recursive
|
||||
(defun max-hailstone-start (limit mx curr)
|
||||
(declare (xargs :mode :program))
|
||||
(if (zp limit)
|
||||
(mv mx curr)
|
||||
(let ((new-mx (len (hailstone limit))))
|
||||
(if (> new-mx mx)
|
||||
(max-hailstone-start (1- limit) new-mx limit)
|
||||
(max-hailstone-start (1- limit) mx curr)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue