March 13Mar 13 ;; BY CLAUDE: (defun happy-step (n) (reduce #'+ (mapcar (lambda (d) (* d d)) (digits n)))) (defun (n &optional acc) "Sequenz bis Fixpunkt 1 oder bis Zyklus erkannt." (let ((acc (or acc (list n)))) (let ((next (happy-step n))) (if (member next acc) (append acc (list next)) ; Zyklus: letztes Element zeigt wohin (happy-seq next (append acc (list next))))))) (happy-seq (rnd-pick (happy-numbers 100))) (list-plot (loop repeat 10 collect (flatten (happy-seq (rnd-pick (happy-numbers 300))))) :join-points t)
Create an account or sign in to comment