fork download
  1. ; highly composite numbers
  2.  
  3. (define (zip . xss) (apply map list xss))
  4.  
  5. (define (nod x)
  6. (let loop ((n 2) (z 2))
  7. (if (= z x) n
  8. (if (zero? (modulo x z))
  9. (loop (+ n 1) (+ z 1))
  10. (loop n (+ z 1))))))
  11.  
  12. (define (hcp limit)
  13. (let loop ((x 2) (y (list 1)) (z (list 1)))
  14. (if (< limit x) (reverse (zip y z))
  15. (let ((n (nod x)))
  16. (if (< (car z) n)
  17. (loop (+ x 1) (cons x y) (cons n z))
  18. (loop (+ x 1) y z))))))
  19.  
  20. (display (hcp 1000)) (newline)
Success #stdin #stdout 10.78s 9832KB
stdin
Standard input is empty
stdout
((1 1) (2 2) (4 3) (6 4) (12 6) (24 8) (36 9) (48 10) (60 12) (120 16) (180 18) (240 20) (360 24) (720 30) (840 32))