Collatz problem or conjecture



On Friday 19 December 2008 19:29:35 Luigi Marino wrote:
> It is possible in Maxima
> implementation of Collatz sequence ?
> Have you did ?
> Luigi Marino

  n_collatz (n) := block ([seq : []],
    while (n > 1) do (
      seq : cons (n, seq),
      n : if oddp(n) then 3*n + 1 else n / 2
    ),
    reverse (seq)
  )$

Or

  (defun collatz (n)
    (let ((seq nil))
      (loop while (> n 1) do
        (setf seq (cons n seq))
        (setf n (if (oddp n) (1+ (* n 3)) (/ n 2))))
      (reverse seq)))

  (defun $collatz (n) (cons '(mlist) (collatz n)))

-- 
Prickle Prickle, Aftermath 62 YOLD 3174
Alexey Beshenov  http://beshenov.ru/