March 13Mar 13 ;; BY CLAUDE: ;; Aliquot-Sequenz (Summe echter Teiler, Zyklus = befreundete Zahlen) (defun aliquot-seq (n &optional acc) "Sequenz n → Σ(echte Teiler) bis 0, Fixpunkt oder Zyklus." (let ((acc (or acc (list n)))) (let ((next (reduce #'+ (proper-divisors n) :initial-value 0))) (cond ((zerop next) (append acc (list 0))) ; endet bei 0 ((member next acc) (append acc (list next))) ; Zyklus (t (aliquot-seq next (append acc (list next)))))))) (list-plot (aliquot-seq (random 100)) :join-points t) (list-plot (loop repeat 10 collect (aliquot-seq (random 100))) :join-points t)
Create an account or sign in to comment